If I wanted to exclude some columns (Ozone
, Day
, Month
) that get "gathered" I can do this:
tidyr::gather(airquality, key, value, -Ozone, -Day, -Month)
But in a function, it isn't clear to me how to do this. This seems clumsy though it works:
my_gather <- function(col_to_compare) {
gather_cols = dplyr::setdiff(c("Ozone", "Solar.R","Wind","Temp"), col_to_compare)
tidyr::gather(airquality, key, value, !! rlang::enquo(gather_cols))
}
my_gather("Ozone")
Any idea how to exclude columns in a more rigorous way?
Note: This is with tidyr
0.7.0