I want to filter a data frame so that I only keep columns that have the values 1, 2, 3, 4, 5, or NA in them.
x = data.frame(col1 = c("a" , "b", "d", "e", "f", "g"),
col2 = c(12, 45, 235, 2134, NA, 1),
col3 = c(1, 2, 3, 1, 2, NA),
col4 = c(1, 2, 3, 4, 5, NA),
col5 = c(1, 2, 3, 4, 5, 6))
With this example data, I would like to return x with only col 3 and 4.