Thanks for the almost complete reproducible example, called a reprex. It's missing one vital component, though, the source data. I've located it and am working on reproducing your error. I put some representative data in a gist
Another thing. Avoid using plot
and other R
reserved names. Use my_plot
. For ggplot
, I just use p <- ggplot(...)