Stop gather function from dropping factor labels
I'm trying to use the gather function in tidyr - but it is stripping out the labels from factored data. My data looks something like this: > require(tidyr) > messy = data.frame(x=rep(seq(0,2),2),y=runif(6),z=runif(6),source=c('good','bad')) > messy x y z source 1 0 0.37627685 0.9108316 good 2 1 0.77593147 0.9944256 bad 3 2 0.01105364 0.1183923 good 4 0 0.37755463 0.6761343 bad 5 1 0.86333114 0.7312482 good 6 2 0.69085345 0.8288506 bad >tidy = gather(messy,coordinate,value,y:z) >tidy x source coordinate value 1 0 2 y 0.37627685 2 1 1 y 0.77593147 3 2 2 y 0.01105364 4 0 1 y 0.37755463 5 1 2 y 0