[R] boxplot question in other terms

Ko-Kang Wang Ko-Kang at xtra.co.nz
Fri Apr 7 23:27:07 CEST 2000


I see what you mean now.  You are lucky I did this kind of plot in one of my
previous assignment.  I have modified the data to suit your needs.  The data is
directly quoted from the paper 475.340 Designs of Surveys and Experiments in the
University of Auckland, New Zealand.

# Enter the data, count.
count <- c( 11, 14, 15, 17, 18, 21, 25,
     39, 43, 46, 50, 52, 61, 67,
     88, 92, 104, 113, 119, 120, 130,
     222, 251, 259, 283, 299, 312, 337,
     562,,604, 689, 702, 710, 739, 786 )

# Enter the ordered factor, Test.
# Since the data, count, is kind of like a 7 by 5 matrix, you need to
# repeat Test 1 ~ Test 5 by that amount.
# In other words, "Test" will look something like:
 # 1 1 1 1 1 1 1
 # 2 2 2 2 2 2 2
 # 3 3 3 3 3 3 3
 # 4 4 4 4 4 4 4
 # 5 5 5 5 5 5 5
Test <- ordered( factor( rep( c( 1, 2, 3, 4, 5 ),
         rep( 7, 5 )
       )
                       )
               )


# To draw a boxplot that has Test 1 ~ Test 5 on its x-axis and
# count on its y-axis.
# There should be 5 box&whiskers within the SAME plot box.
boxplot( split( count, Test ),
         xlab = "Test", ylab = "counts",
         main = "A Boxplot" )

To make is easier for you, I have even saved it as an R source file and attached it
below for you.  Just saved it to your disk, use "source()" function in R to source
it in directly.  From the R commands, it should be pretty easy to see how you
should change it to get the plot that you want.  (The # means R comments, it will
NOT affect the plots).

Cheers,

Ko-Kang Wang

Christine Serres wrote:

> First of all, I thanks you all for replying me .
> I've not asked my question in good terms, so I've made a little drawing
> of what I want to do in my boxplot   : - )
>
> |     -                                           -
> |     |                                            |
> |  ----                                   ----
> |  |        |                                  |        |
> |  |    2  |                                  |    2  |
> |   ----                                  ----
> |      |                                            |
> |      -                                          -
> |
> |
> |       -                                         -
> |       |                                           |
> |     ----                                 ----
> |     |        |                                |        |
> |     |    1  |                                |   1   |
> |     ----                                 ----
> |       |                                           |
> |       -                                         -
> |
> ____________________________________________________________________
>
>         Test X                          Test Y
>
> (I don't want my boxes to be shifted  for the same  Test value because I
> know that boxplot 1 and 2 don't overlap)
> I'm not sure that the boxplot function can do that.
> But perhaps someone know a trick to help me.
>
> Thanks
> Christine
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20000408/7bb6a802/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: boxplot.R
Type: application/x-unknown-content-type-r_auto_file
Size: 898 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20000408/7bb6a802/boxplot.bin


More information about the R-help mailing list