A subset data frame must include only one level that is meaningful at both levels of the other factor
I have the following df:
Subject Condition Score
John Hard 1
John Easy 1
Simon Hard 2
Simon Easy 3
Mary Hard 1
Mary Hard 2
Kevin Hard 2
Kevin Easy 3
I would like a subset of this df to only include data from subjects who completed both levels of the "Condition" factor (ie Easy AND Hard). The df result should look like this:
Subject Condition Score
John Hard 1
John Easy 1
Simon Hard 2
Simon Easy 3
Kevin Hard 2
Kevin Easy 3
I've tried the following:
dfNew <- subset(df, Condition==c("Easy", "Hard"), select=Subject)
dfNew2 <- subset(with(df, Subject, Condition == "Easy" & Condition == "Hard"))
But I got error messages and warnings for both.
Any help would be much appreciated.
+1
source to share
No one has answered this question yet
See similar questions:
or similar: