[R] boxplot statistics in ggplot

hadley wickham h.wickham at gmail.com
Wed Feb 7 18:44:42 CET 2007

On 2/7/07, Vikas Rawal <vikasrawal at gmail.com> wrote:
> How can I superimpose some text labels on ggplot?  I could get
> weighted quantiles using wtd.quantiles function in Hmisc package. But
> I can't plot these as labels on the boxplot.
> My code is as follows.
> list(c(1:3),c(1:3),c(1:3))->t
> library(Hmisc)
> for (i in 1:3)
>   {
>     wtd.quantile(crop.2.list[[i]]$aggincome,weights=crop.2.list[[i]]$Multiplier,probs=c(0.25,0.5,0.75))->t[[i]]
>    }
> data.frame(y=round(unlist(t)),x=c(1,1,1,2,2,2,3,3,3))->levels
> library(ggplot)
> ggplot(crop.2.cast,aesthetics=list(x=Tenurial.status,y=aggincome, weight=Multiplier),labels=c("ts","in"))->p
> ggtext(ggboxplot(p),aesthetics=list(x=x,y=y,labels=y),data=levels)

That should work.  Are you able to send me the data so I can check it myself?

> Finally, a relatively minor issue at the moment, is it possible to
> change the x-axis and y-axis labels?

Yes:  p$xlabel <- "X label"; p$ylabel <- "Y label"


More information about the R-help mailing list