I'm a beginner to R and am having trouble indexing into a dataframe using a vector of column values.
I want to select all the rows from 2 participants.
data is the data frame. participant is a column
data[data$participant == c(8, 10),])
I thought this should give me all the rows from both participants 8 and 10, but instead it is giving me half of the rows from participant 8 and half from participant 10. In other words,
dim(data[data$participant == c(8, 10),]) is the same as dim(data[data$participant == 8,]) or dim(data[data$participant == 10,]) rather than double.
The problem seems to be with the syntax of indexing these multiple column types:
data$participant == c(8, 10)
I'd be grateful for any tips on how to do this (without doing each participant separately)! Thank you!