[R] boxplot with grouped variables

S Ellison S.Ellison at LGCGroup.com
Sat May 11 20:20:35 CEST 2013


You can't mix number and character data in a data frame column, so you will probably find that all your variables are factors, not numbers. Try, for example
class(Daten$V2)

It looks like you failed to specify 'header=TRUE' in a read.table statement. Reread the data with headers properly treated so that those first items become the variable names.

In additon, Daten$V2[Daten$V3=="m"]) will only give you data for rows in which V3=="m", which will be a single boxplot. (see ?"[" for what that subsetting operation does). To plot all combinations ( if V2 were correctly numeric) you could try
boxplot(V2~V1+V3, data=Daten)

S Ellison
________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of maggy yan [kiotoqq at gmail.com]
Sent: 11 May 2013 16:40
To: R-help at r-project.org
Subject: [R]  boxplot with grouped variables

my dataset looked like this in the beginning:

>Daten
      V1      V2         V3
1  Dosis Gewicht Geschlecht
2      0    6.62          m
3      0    6.65          m
4      0    5.78          m
5      0    5.63          m

I need box plots for V2 with all combination of V1 and V3, so I deleted the
first row, and tried this:
boxplot(Daten$V2[Daten$V3=="m"])
but it does not work and I have no clue what I did wrong.
I'm thankful for any help!

        [[alternative HTML version deleted]]

______________________________________________
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.

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list