Filter function filtering everyting?

I'm trying to isolate my dataset by rows and, due to multiple people working on this data set one group of data has tow names those being chem and, chemistry, It could be that I'm miss using tidyverse but what I'm trying to do is isolate only the rows that are labeled chem and chemistry.
When I run this code the resultant data is blank.
My code is shown below, any help would be appreciated!

# remove all columns with irrelevant data.
# remove everything except discipline, class date, and codes.
data <- subset(data, !is.na(data$instructor))
data_subject_code <- data[,c(7,9,14:30)]
# Isolate data from chemistry discipline
data_chemistry_code <- data_subject_code %>%
                  filter(course_subject_code=="chem", course_subject_code=="chemistry")

Your filter requirements are that course_subject_code has to equal "chem" AND it must equal "chemistry". I think you want

data_chemistry_code <- data_subject_code %>%
                  filter(course_subject_code=="chem" | course_subject_code=="chemistry")

where | means OR.

1 Like

also useful to know of the %in% operator that checks for membership in the set, so can be thought of as equivalent to | or

 filter(course_subject_code %in% c("chem","chemistry"))
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.