[R] connecting boxplots
David Winsemius
dwinsemius at comcast.net
Mon Jan 12 07:26:06 CET 2009
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
>>
More information about the R-help
mailing list