Really struggling with this.
a & b are actual datasets in the real world, a being extremely large. I get an error ggplot2 doesn’t know how to deal with data of class uneval. What I’m trying to do is overlay a single point from a second data set on to the boxplot to highlight how one particular sample compared to a universe.
Any idea what I’m doing wrong? How can I fix it?
a = data.frame(YTD.Retn=runif(1000,-10,10),sector="a")
a = rbind(a,data.frame(YTD.Retn=runif(1000,-10,10),sector="b"))
a = rbind(a,data.frame(YTD.Retn=runif(1000,-10,10),sector="c"))
a = rbind(a,data.frame(YTD.Retn=runif(1000,-10,10),sector="d"))
a = rbind(a,data.frame(YTD.Retn=runif(1000,-10,10),sector="e"))
a = rbind(a,data.frame(YTD.Retn=runif(1000,-10,10),sector="f"))
a = rbind(a,data.frame(YTD.Retn=runif(1000,-10,10),sector="g"))
b = data.frame(sector=c("a","b","c","d","e","f","g"),YTD.Retn=c(5,6,7,3,2,-1,-5))
p1 =ggplot(a,aes(factor(sector),YTD.Retn,fill=factor(sector))) + geom_boxplot() +
scale_fill_discrete(guide=F) +
geom_point(b,aes(factor(sector),YTD.Retn))
plot(p1)
You need to name the argument
datawhen called within ageom_...()call. Naming arguments is good practice in general (if somewhat timeconsuming)