Skip to content

connecting boxplots

8 messages · johnhj, David Winsemius, David Hajage +1 more

#
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
#
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:

  
    
#
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
#
Thank you very much David...

Can you also describe me how to describe the standard deviation of the
boxplots/matrices ?
David Winsemius wrote:

  
    
#
> Can you also describe me how to describe the standard
    > deviation of the boxplots/matrices ?
 
Try tapply:

    > x <-read.table(file="test.txt")	
    > x$group <- rep(1:8, each=5)
    > boxplot(V3~gruppe, data=x) 


with(x, tapply(V3, gruppe, sd))


Mike
#
Hiii,

Thanks to all...

Btw.: Is it possible to disable the description of extrem points in
boxplots. I mean the points under the whisker's...in the image you can see
what I mean...

greetings,
J http://www.nabble.com/file/p21425697/Test_Delay3_1_2.png
Michael A. Miller wrote:

  
    
#
@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: