[R] Box Plot under GUI (R Commander/RKward)

Dennis Murphy djmuser at gmail.com
Tue May 17 22:14:02 CEST 2011


Hi:

I'm assuming this is a snippet of a much larger data set, because one
certainly would not use box plots on singleton observations. You have
four grouping variables in your example, so the best you could likely
do on one graphics page would be to, for example, plot time vs.
distance, 'dodged' by season, say, which would have to be distributed
over separate panels defined by combinations of transporter and
tonnage. This is certainly possible in lattice and ggplot2, with the
latter being a bit more direct for this particular problem. Here is a
reproducible example:

df <- data.frame(Season = factor(rep(c(1, 2), each = 120)),
                   Transporter = factor(rep(rep(c(1, 2), each = 60), 2)),
                   Tonnage = factor(rep(rep(c(1, 2), each = 30), 8)),
                   Distance = factor(rep(rep(c(500, 1000, 1500), each
= 10), 8)),
                   Time = rpois(240, 25))

library(ggplot2)
ggplot(df2, aes(x = Distance, y = Time, fill = Season)) +
       geom_boxplot(position = 'dodge') +
       facet_grid(Transporter ~ Tonnage)

You probably want more evocative labels for the factor variables to
make them interpretable, but that's the general idea. It is also
possible to customize the graph in several ways. To do this
interactively, you would likely need to use the Deducer package in
conjunction with rJava, as Liviu suggested. See the package web page
http://www.deducer.org/pmwiki/pmwiki.php?n=Main.DeducerManual

which shows you how to get started. The videos are very useful, too.
Its author, Ian Fellows, has kindly provided an 'all-in-one' installer
for R-2.13.0, rJava (+ its dependencies) and Deducer. I would
certainly go this route if you're not adept at installing R packages,
and would particularly recommend this service on Windows. Deducer has
a GUI like rkward and Rstudio, but it has a more user-friendly menu
system analogous to R Commander. It does, however, require Java, so
you (and your clients) need to have it installed on your systems.

HTH,
Dennis


On Tue, May 17, 2011 at 4:31 AM, Vikas Garud
<information4vikas at gmail.com> wrote:
> Hi,
>
> I am a consultant in Quality Management.  I am exploring the use of R
> with any GUI - R commander/Rkward for doing analytical work.  Have
> installed R, R Commander and Rkward.
>
> I hope to learn by doing various exercises that I use for teaching
> analytical techniques to my clients.  I would be posting the data on
> this mailing list, and the rkward mailing list wherever I get stuck.
>
> First such technique I am trying to explore is the use of boxplots.
> The data is pasted below:
> Season  Transporter     Distance        Tonnage Time
> 1       1       500     1       17
> 1       1       500     2       22
> 1       1       1000    1       23
> 1       1       1000    2       29
> 1       1       1500    1       33
> 1       1       1500    2       38
> 1       2       500     1       19
> 1       2       500     2       26
> 1       2       1000    1       30
> 1       2       1000    2       35
> 1       2       1500    1       42
> 1       2       1500    2       42
> 2       1       500     1       18
> 2       1       500     2       24
> 2       1       1000    1       25
> 2       1       1000    2       26
> 2       1       1500    1       35
> 2       1       1500    2       38
> 2       2       500     1       21
> 2       2       500     2       24
> 2       2       1000    1       28
> 2       2       1000    2       37
> 2       2       1500    1       36
> 2       2       1500    2       44
>
> In this exercise, I am trying to plot box plots of the variable
> "Time", the last column and separated by all the other variables-
> Season, Transporter, Distance and Tonnage.  I expect the output in
> form of multiple box plots, arranged side by side so that I can
> compare the time performance for, say, season 1, transporter 2,
> Distance 500 and tonnage 2 with, say, season 2, transporter 1,
> Distance 500 and tonnage 2.  The box plot command in R Commander
> (Grpahs->Boxplot...) has a button called "plot by groups" presumably
> to achieve what I am trying to do.  However, on clicking I don't get
> any further output.  What am I missing?  (There is nothing equivalent
> to this button under Rkward)
>
> I tried to search the mailing list on box plot, but could not find
> anything relevant.  I have also searched in manual and seen this type
> (or even more complex analysis) being done on terminal.  However, I
> need to do it under (any) GUI.  Any help is highly appreciated.
>
> Thanks
> Vikas Garud
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list