Thanks. Using this data frame
dframe <-
data.frame(
Subject_Number = 1:10,
gender = c("female", "male", "female", "female", "female",
"female", "male", "female", "male", "male"),
wrong_answers = c(0, 1, 0, 0, 0, 0, 1, 0, 0, 1),
stringsAsFactors = FALSE
)
You can do this with either
AnsweredCorrectly <- dframe[dframe$wrong_answers == 1, ]
or if you prefer dplyr syntax
library(dplyr)
AnsweredCorrectly <-
filter(dframe,
wrong_answers == 1)
unrelated note
As a note in case you need help in the future, one way to make it easier to help is to give us code that generates your sample data. head and dput are functions that are really helpful for that. For instance,
dput(head(dframe, 10))