Hi,

The form of the data is not terribly important neither is whether it
was sorted as boxplots are not order dependent are category "a" is "a"
sorted or not.  See below for individual plots with your new data.


# read in data
dat <- read.table(textConnection("
1  a  12
2  b  4
3  a  3
4  c  54
5  a  12
6  b  11
7  c  9
8  c  2
"), header = FALSE)
closeAllConnections()

# add names since you said they lack them
names(dat) <- c("id", "cat", "value")

# this makes it so it will ask for input before
# changing plots
par("ask" = TRUE)

# run the function boxplot for different values by() each level in dat$cat.
# if par("ask" = TRUE) was set, it should make you click or hit
# return before changing each plot
by(dat$value, dat$cat, boxplot)



HTH,

Josh

On Wed, Sep 29, 2010 at 3:01 AM, deadlyspider <wrcst...@gmail.com> wrote:
>
> Ok, I don't think I was specific enough.
>
> The data originally came in this form
>
>
> 1  a  12
> 2  b  4
> 3  a  3
> 4  c  54
> 5  a  12
> 6  b  11
> 7  c  9
> 8  c  2
> .  .  .
> .  .  .
> .  .  .
>
>
>
> Where I sorted by the second column (NB the second column is the categories
> and they have long names). I would then like separate boxplots for each
> category.
>
> The loop idea would be nice but unfortunately I do not fully understand the
> answer given.
>
> Thanks.
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Splitting-data-in-to-multiple-boxplots-tp2717491p2718659.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

______________________________________________
R-help@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.

Reply via email to