I am trying to use gather in the tidyr package, but I cannot change the names of the derived columns from the default names. For instance:
df = data.frame(time = 1:100,a = 1:100,b = 101:200) df.long = df %>% gather("foo","bar",a:b) colnames(df.long)
gives me
[1] "time" "variable" "value"
but shouldn't be "time" "foo" "bar" ?
I can change "foo" and "bar" to whatever I want, and it still gives me "variable" and "value" as the names of my columns.
Reference. What am I missing here?
source share