I'm trying to use gather
in the tidyr
package, but I'm not able to change the outputted column names 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 it be "time" "foo" "bar"
?
I can change "foo" and "bar" to anything I want, and it still gives me "variable" and "value" as my column names.
Help. What am I missing here?