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
To drop empty factor levels from a subset, I use the following:
a.subset <- subset(dataset, Color!='BLUE')
ifac <- sapply(a.subset,is.factor)
a.subset[ifac] <- lapply(a.subset[ifac],factor)
Mike
> dataset
Color Score
1 RED10
2 RED13
3 RED12
4 WHITE22
5 WHITE27
6 WHIT
David Winsemius wrote:
How can I eliminate the BLUE category completely so I can do a t-test
using
Color (with just the RED and WHITE subjects)?
dataset$Color <- as.character(dataset$Color)
or factor(dataset$Color), even. As has been pointed out already,
t.test.formula et al. do this in
David Winsemius wrote:
>
> t.test expects two numeric vectors, not a numeric vector and a
> grouping indicator.
>
> > t.test(dataset[dataset$Color=="RED", "Score"], dataset[dataset
> $Color=="WHITE", "Score"] )
>
>
Thank you again, David! I also just realized I could have replaced the
On Aug 21, 2009, at 6:36 PM, Don McKenzie wrote:
Right, but he just wanted to eliminate "BLUE" as far as I could see.
Read his message again. He already showed three methods all of which
gave results identical to the one you offered. He asked to be shown
why the 0's were appearing in tabl
On Aug 21, 2009, at 6:35 PM, jlwoodard wrote:
Thank you David!
David Winsemius wrote:
How did you do the "t-test"?
t.test(Score,Color)
?t,test
t.test expects two numeric vectors, not a numeric vector and a
grouping indicator.
> t.test(dataset[dataset$Color=="RED", "Score"],
Right, but he just wanted to eliminate "BLUE" as far as I could see.
Your solution does more, of course.
On 21-Aug-09, at 3:33 PM, David Winsemius wrote:
On Aug 21, 2009, at 6:16 PM, Don McKenzie wrote:
dataset[dataset$Color != "BLUE",]
Will return a data.frame with Color still a facto
Thank you David!
David Winsemius wrote:
>
>
> How did you do the "t-test"?
>
>
t.test(Score,Color)
John
--
View this message in context:
http://www.nabble.com/Selecting-groups-with-R-tp25088073p25088342.html
Sent from the R help mailing list archive at Nabble.com.
_
On Aug 21, 2009, at 6:16 PM, Don McKenzie wrote:
dataset[dataset$Color != "BLUE",]
Will return a data.frame with Color still a factor with three levels.
On 21-Aug-09, at 3:08 PM, jlwoodard wrote:
I have a data set similar to the following:
Color Score
RED 10
RED 13
RED
On Aug 21, 2009, at 6:08 PM, jlwoodard wrote:
I have a data set similar to the following:
Color Score
RED 10
RED 13
RED 12
WHITE 22
WHITE 27
WHITE 25
BLUE 18
BLUE 17
BLUE 16
and I am trying to to select just the values of Color that are equal
to RED
or WH
Hi John,
I would guess that your Color column is a factor, with three levels
("RED","BLUE","WHITE"), which means that they will all be included in
the output of a table() call, even if they are empty. Try
dataset <- transform(dataset, Color=as.character(Color))
or something similar and then crea
dataset[dataset$Color != "BLUE",]
On 21-Aug-09, at 3:08 PM, jlwoodard wrote:
I have a data set similar to the following:
Color Score
RED 10
RED 13
RED 12
WHITE 22
WHITE 27
WHITE 25
BLUE 18
BLUE 17
BLUE 16
and I am trying to to select just the values of Color
I have a data set similar to the following:
Color Score
RED 10
RED 13
RED 12
WHITE 22
WHITE 27
WHITE 25
BLUE 18
BLUE 17
BLUE 16
and I am trying to to select just the values of Color that are equal to RED
or WHITE, excluding the BLUE.
I've tried the following:
m
13 matches
Mail list logo