All the code I used is below:
df <- data.frame("StudyID" = paste("Study", seq(1:100), sep = "_"),
"Score" = sample(c(-15:30),100, replace = TRUE))
df$Result<- ifelse(df$Score > 20, "great",
ifelse(df$Score < -5, "bad", "neutral"))
I want to create a NEW dataframe1 that contains the "StudyID" and "Score" only for people who have a Result that is equal to "great". The resulting columns should only contain "StudyID"and "Score" and not the Result column.
Then I want to creat another NEW dataframe2 for the people who have a Result that is equal to "bad" with the columns "StudyID" and "Score".
Your help is really appreciated!