Hi, everyone! I'm trying to write some code that returns a new dataframe without certain rows if a condition is true. In the tibble below, I have the study name, the test used in the study, and code that corresponds to the type of test used in the study. To reduce dependencies in the dataset, I want to write some code that tells me whether or not, for each study in the data, the study has both a total test score ("2") and score for only a subsection ("1") of the total test ("reading", "writing", etc.). So, I want to write code that says, "For each study, if the study has both a 2 and a 1, return a new df without the 2's". Any help with this? Thanks!
df <- tibble(
Study = c(rep("Todd (2002)", 5), rep("Liz (2004)", 5)),
Test = c("TOEFL (total)", "TOEFL (reading)", "TOEFL (writing)", rep("cloze", 2),
"IELTS (total)", "IELTS (listening)", "IELTS (speaking)", rep("c-test", 2)),
Code = c(2, 1, 1, 0, 0, 2, 1, 1, 0, 0)
)