Dear, I am a newbie to R. Now I am learning to draw boxplot using graphics(). I want to highlight the median position with a round point and the value left (or on the top of)to the point. Please kindly share the command and thank you. Elaine [[alternative HTML version deleted]]
milton ruser
2010-Jan-02 07:10 UTC
[R] Boxplot- input the median point and the median value
Dear Elaine, The posting guide is http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> bests milton On Fri, Jan 1, 2010 at 8:53 PM, elaine kuo <elaine.kuo.tw@gmail.com> wrote:> Dear, > > I am a newbie to R. > > Now I am learning to draw boxplot using graphics(). > > I want to highlight the median position > > with a round point and the value left (or on the top of)to the point. > > > > Please kindly share the command and thank you. > > Elaine > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
On 01/02/2010 12:53 PM, elaine kuo wrote:> Dear, > > I am a newbie to R. > > Now I am learning to draw boxplot using graphics(). > > I want to highlight the median position > > with a round point and the value left (or on the top of)to the point. > > >Hi Elaine, For your boxplot questions, I'll use the first example from the boxplot help page: boxplot(count ~ spray, data = InsectSprays, col = "lightgray",yaxt="n") axis(2,c(2,8,14,20),c(2,8,14,20)) For the "dotted to solid" question: boxplot_info<-boxplot(count ~ spray, data = InsectSprays,col = "lightgray") segments(rep(1:6,each=2),boxplot_info$stats[c(1,4),], rep(1:6,each=2),boxplot_info$stats[c(2,5),]) And finally, for the median value question: boxplot_info<-boxplot(count ~ spray, data = InsectSprays, col = "lightgray") points(1:6,boxplot_info$stats[3,]) text(1:6,boxplot_info$stats[3,]+1,boxplot_info$stats[3,]) A bit messy, but you get the idea. Jim