[R] Selecting groups with R
Glen Sargeant
gsargeant at usgs.gov
Mon Aug 24 18:48:11 CEST 2009
jlwoodard wrote:
>
>
> Each of the above lines successfully excludes the BLUE subjects, but the
> "BLUE" category is still present in my data set; that is, if I try
> table(Color) I get
>
> RED WHITE BLUE
> 82 151 0
>
> How can I eliminate the BLUE category completely so I can do a t-test
> using Color (with just the RED and WHITE subjects)?
>
>
A simpler example. See "details" in the help file for factor() for an
explanation.
>#Factor with 3 levels
> x <- rep(c("blue","red","white"),c(1,1,2))
>
> x <- factor(x)
>
> table(x)
x
blue red white
1 1 2
>
>#Subset is still a factor with 3 levels
> y <- x[x!="blue"]
>
> table(y)
y
blue red white
0 1 2
>
>#Drops unused levels; result a factor with 2 levels
> table(factor(y))
red white
1 2
--
View this message in context: http://www.nabble.com/Selecting-groups-with-R-tp25088073p25119474.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list