[R] Overlay Boxplot with scatter plot

Joris De Wolf joris.dewolf at cropdesign.com
Tue Aug 1 14:53:34 CEST 2006


boxplot does not use the actual values of aa as x-value, but considers 
aa as a factor having three levels.

Try

bxp <- boxplot(bb~aa, data=nn)
bxp

to see what the boxplot actually is.
For your lines you should also use three levels.

aa2<-c(1,1,1,1,2,2,2,2,3,3,3,3,3,3,3)
points(cc~aa2)

(after you have been correcting your example code...)
Joris


Lanre Okusanya wrote:
> I am trying to make a box plot and overlay it with a scatter plot from
> another data.frame. I was able to successfully create the boxplot, but
> when i tried using points(x~y...) the dots did not show up.
> 
> example code
> 
> aa<-(300,300,300,300,600,600,600,600,900,900,900,900)
> bb<-(13,12,14,11,56,44,34,75,22.,34,22,98,59,55,56)
> cc<-(13,12,14,11,56,44,34,75,22.,34,22,98,59,55,56)
> nn<-data.frame(aa,bb)
> mm<-data.frame(aa,cc)
> boxplot(bb~aa, data=nn)
> lines(cc~aa, data=cc)
> 
> Any help with example code is appreciated.
> 
> Thank you.
> 
> Lanre
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


confidentiality notice:
The information contained in this e-mail is confidential and...{{dropped}}



More information about the R-help mailing list