I have a data frame with observations (rows) and variables (columns). I now want to create a subset of observations who meet certain criteria. The relevant variables all start with "incl_", they are numbered from 1 to 5 and equal 1 if fulfilled (e.g., "incl_1" = 1).
Is there a more efficient way of doing the following:
redcap <- df[df$incl_1 == 1 &df$incl_2 == 1 & df$incl_3 == 1 & df$incl_4 == 1 & df$incl_5,]
I tried this which obviously does not work, but might give you an idea of what I am trying to do:
df2 <- filter(df, select(df, startswith("incl")) ==1)