I'm trying to learn how to use tidyr to transfor wide data to long. Suppose my data looks like this:
df1 <- data.frame(V1=c(1.5,7.4),
V2=c(6.7,8.8),
sim=c(1,2))
I want to transform me to look like this:
df2 <- data.frame(sim=c(1,1,2,2),
Value=c(1.5,6.7,7.4,8.8))
I think gather is the function that I have to use, but I'm not understanding the help file. This is what I have right now:
df1 %>%
gather(key=sim, value=V1:V2)
The error says "Error: Invalid column specification"
Thanks!