[R] connecting boxplots

johnhj jharris at web.de
Tue Jan 13 00:53:11 CET 2009


@David Winsemius

I have one more question to you...
lines(boxplot(count ~ spray, data = InsectSprays, col = "lightgray") 
$stats[c(1),]  )
connects the lines through the values.

But how can I connect the values min, max, median at the same time ?
The code above make only one line, if I use this line above second time with
an another row of the matrix, the first line of the max values are
overwritten. How can I use:

-$stats[c(1),]
-$stats[c(3),]
-$stats[c(5),]

at the same time ?




David Winsemius wrote:
> 
> You do not provide a workable example and it appears you may be  
> conflating the German and English spellings of "group", but perhaps  
> this code fragment using the first example in boxplots help menu will  
> move you along. It results in drawing the connecting lines to the  
> minimum value in each group.
> 
>  > boxplot(count ~ spray, data = InsectSprays, col = "lightgray")   
> #draws the plot
>  > str(boxplot(count ~ spray, data = InsectSprays, col = "lightgray")  )
> List of 6
>   $ stats: num [1:5, 1:6] 7 11 14 18.5 23 7 12 16.5 18 21 ...
> 
> # Notice that the "stats" element is a matrix that has the first row  
> as the minimums, third as the medians, and maxs are fifth.
> 
>   $ n    : num [1:6] 12 12 12 12 12 12
>   $ conf : num [1:2, 1:6] 10.579 17.421 13.763 19.237 0.588 ...
>   $ out  : num [1:2] 7 12
>   $ group: num [1:2] 3 4
>   $ names: chr [1:6] "A" "B" "C" "D" ...
> 
>  > boxplot(count ~ spray, data = InsectSprays, col = "lightgray") 
> $stats[c(1,5),]
>       [,1] [,2] [,3] [,4] [,5] [,6]
> [1,]    7    7    0    2    1    9  # minimums
> [2,]   23   21    4    6    6   26  # maximumns
> 
>  > lines(boxplot(count ~ spray, data = InsectSprays, col = "lightgray") 
> $stats[c(1),]  )  #adds the lines through minimums
> 
> -- 
> David Winsemius
> 
> On Jan 11, 2009, at 8:00 PM, johnhj wrote:
> 
>>
>> In other words: I will connect the median, min and the max area of the
>> boxplot with a line.
>> The function lines() could help me, but I don't know which  
>> parameters the
>> lines() function should have.
>>
>> johnhj wrote:
>>>
>>> Hii,
>>>
>>> I created some boxplots with this commands:
>>>
>>> x <-read.table(file="test.txt")	
>>> x$group <- rep(1:8, each=5)
>>> boxplot(V3~gruppe, data=x)
>>>
>>> Now, I will connect the boxplots to each other to the min, max and  
>>> median
>>> values.
>>> Can anybody help me how to do it ?
>>>
>>> greetings,
>>> J
>>>
> 
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/connecting-boxplots-tp21405459p21426682.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list