[R] How am i able to create Box plots of a factor (weight) separated by other factors (breed)?
Lyle Warren
lyle00 at gmail.com
Sun Mar 15 23:50:53 CET 2015
Thanks very much everybody - I think i've got it now!
On 15 March 2015 at 23:58, John Kane <jrkrideau at inbox.com> wrote:
> Oops missed the links. Once more...
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> http://xkcd.com/1478/
>
> John Kane
> Kingston ON Canada
>
>
> > -----Original Message-----
> > From: jrkrideau at inbox.com
> > Sent: Sun, 15 Mar 2015 04:53:39 -0800
> > To: lyle00 at gmail.com, r-help at r-project.org
> > Subject: Re: [R] How am i able to create Box plots of a factor (weight)
> > separated by other factors (breed)?
> >
> > As a follow up to Thierry's response.
> >
> > With data as dat1
> >
> > dat1 <- structure(list(id = 1:12, weight = c(453L, 527L, 520L, 460L,
> > 496L, 461L, 519L, 472L, 531L, 473L, 509L, 503L), breed = c("brahman",
> > "brahman", "brahman", "brahman", "durham", "durham", "durham",
> > "durham", "durham", "durham", "durham", "durham")), .Names = c("id",
> > "weight", "breed"), class = "data.frame", row.names = c(NA, -12L
> > ))
> >
> > library(ggplot2)
> > ggplot(dat1, aes(breed, weight)) +
> > geom_boxplot()
> > library(ggplot2)
> > ggplot(dat1, aes(breed, weight)) +
> > geom_boxplot()
> >
> > I would note that it is difficult to break down the data by breed when
> > your sample data only included brahman as a breed. In the sample data
> > above I changed a few entries to my favourite breed of Durham.
> >
> > Have a look at one (or both) of these links for some useful suggestions
> > on how to ask questions on R-help. In particular, read about dput. It
> > is by far the best way to supply sample data for the readers.
> >
> > Good luck
> >
> > John Kane
> > Kingston ON Canada
> >
> >
> >> -----Original Message-----
> >> From: lyle00 at gmail.com
> >> Sent: Sun, 15 Mar 2015 14:50:22 +1100
> >> To: r-help at r-project.org
> >> Subject: [R] How am i able to create Box plots of a factor (weight)
> >> separated by other factors (breed)?
> >>
> >>>
> >>>
> >>> I have data with columns for animal ID, breed, and weight.
> >>>
> >>> I'd like to create a box plot of weight, separated by breed (there are
> >>> 4
> >>> breeds).
> >>>
> >>> Any ideas?
> >>>
> >>> Here's a sample of the data (there are 100 rows):
> >>>
> >>> id weight breed
> >>> 1 453 brahman
> >>> 2 527 brahman
> >>> 3 520 brahman
> >>> 4 460 brahman
> >>> 5 496 brahman
> >>> 6 461 brahman
> >>> 7 519 brahman
> >>> 8 472 brahman
> >>> 9 531 brahman
> >>> 10 473 brahman
> >>> 11 509 brahman
> >>> 12 503 brahman
> >>>
> >>> Thanks for your help!
> >>>
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> 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.
> >
> > ____________________________________________________________
> > FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
> >
> > ______________________________________________
> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>
> ____________________________________________________________
> Send any screenshot to your friends in seconds...
> Works in all emails, instant messengers, blogs, forums and social networks.
> TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE
>
>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list