Reputation: 481
Suppose I have a data.frame that looks something like this:
ball1 ball2 ball3 allRed
red red blue F
red red red T
blue blue red F
. . . .
. . . .
. . . .
And so on. I wish to extract the first 5 rows of the data frame in which allRed are TRUE, and the first 5 rows of the data.frame in which allRed are FALSE. I stored the data.frame in a variable ball
. Below is what I had tried to little avail:
ball[,1][ball$allRed==F]
Upvotes: 0
Views: 61
Reputation: 193687
You should subset allRed
first, and then 5 rows from that. Also, pay attention to your commas. Try:
ball[ball$allRed == TRUE, ][1:5, ]
Upvotes: 1