[R] Simple Question: adding points to a boxplot

David Winsemius dwinsemius at comcast.net
Sat Aug 8 04:20:48 CEST 2009


On Aug 7, 2009, at 8:33 PM, Farley, Robert wrote:

> Sorry to keep bothering you all.  Phil's easy fix got my code  
> working and I have my graphic.
>
> Just for my education: Is there a SIMPLE way to verify/ensure that  
> the ordering of the data is the same in both dataframes?  Is this  
> done within the plotting routines, or is it usually as a data  
> checking process before data analysis?
>
>
One way:
> ==============================================
> boxplot(ObsRpdData[ , c("Blue", "Green", "Red", "Gold", "Orange")] )
> points(1:length(EstRpdData),EstRpdData[ , c("Blue", "Green", "Red",  
> "Gold", "Orange")], pch=16, col="red)
> ===============================================

-- 
Regards;
DW

> Robert Farley

> -----Original Message-----
> From: Farley, Robert
> Sent: Friday, August 07, 2009 15:56
> To: 'Phil Spector'
> Subject: RE: [R] Simple Question: adding points to a boxplot
>
> Whoo-hoo, I get the points!
>
> Thanks!
>
> I guess I was over-thinking it.  :-)
>
> Robert Farley
> Metro
> www.Metro.net
>
> -----Original Message-----
> From: Phil Spector [mailto:spector at stat.berkeley.edu]
> Sent: Friday, August 07, 2009 15:53
> To: Farley, Robert
> Subject: Re: [R] Simple Question: adding points to a boxplot
>
> Robert -
>    What happens when you try
>
> points(1:length(Est1),Est1, pch=23, col="red")
>
>                                        - Phil Spector
>                                         Statistical Computing Facility
>
> On Fri, 7 Aug 2009, Farley, Robert wrote:
>
>> I apologize in advance for the simplicity of this question.  I use  
>> R 2-3 times a year, and I seem to forget more in the intervening  
>> months than I learn during my days of panicked reading....  I HAVE  
>> tried looking at the help resources; I'm just not very good at  
>> understanding them.
>>
>> I have a dataframe with 18 observations of 5 different things, and  
>> a second dataframe with and estimate for those 5 things.  I'm  
>> trying to add the estimated points to the boxplot of observations.   
>> I THINK I'm failing because I need to decompose my estimated  
>> dataframe into two vectors.  I can't seem to figure out how to do  
>> that properly, or if I'm suffering from a different  
>> misunderstanding....
>>
>>
>> ======================================
>> The following code creates the box plot,
>> but the points are not added
>> ======================================
>>> Obs1
>>   Blue Green    Red  Gold Orange
>> 1  77902 32911 117543 18245     NA
>> 2  77294 32204 114927 18377     NA
>> 3  75737 31484 115265 18529     NA
>> 4  73366 31130 112371 14748     NA
>> 5  77061 33601 118113 16910  16360
>> 6  75177 32383 113825 14417  15492
>> 7  76766 35697 124304 16318  16100
>> 8  80378 36374 128091 15325  17636
>> 9  84078 37473 138219 15769  18242
>> 10 81704 37247 136345 15587  18700
>> 11 84554 39134 143830 18078  21828
>> 12 80411 37487 137583 18771  20844
>> 13 76103 34734 131469 20329  20760
>> 14 76246 34591 127921 18874  19531
>> 15 72025 33645 118279 20972  21005
>> 16 72295 35153 121752 18035  20217
>> 17 71287 32961 121958 17768  20659
>> 18 71778 32833 123990 17956  19004
>>> Est1
>>  Blue Green    Red  Gold Orange
>> 1 72289 32444 107121 20900  21962
>>> boxplot(Obs1)
>>> points(Est1, pch=23, col="red")
>>>
>> ======================================
>>
>> Robert Farley
>> Metro
>> 1 Gateway Plaza
>> Mail Stop 99-23-7
>> Los Angeles, CA 90012-2952
>> Voice: (213)922-2532
>> Fax:    (213)922-2868
>> www.Metro.net

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list