Station_list = rep(c("ABC", "DEF", "GHI", "JKL", "MNO", "PQR"), each = 61)
testframe = data.frame(Station = Station_list)
testframe$Value = seq(from = 10, to = 25, length.out = 366)
testframe$Date = seq(ymd('2000-01-01'),ymd('2000-12-31'),by='day')
I want to reshape this dataframe into this format:
Date Station_ABC Station_DEF Station_GHI Station_JKL Station_MNO Station_PQR
2000-01-01 correct_values
I tried to reshape my dataframe in many different ways, but nothing worked how I wanted it.
library(reshape)
test <- cast(testframe, Date + Value ~ Station)
library(furniture)
test = wide (testframe, v.names = "Station", timevar = "Date", id = "Value")
test = wide (testframe, v.names = NULL, timevar = "Station", id = c("Value", "Date"))
test = reshape(testframe, v.names="Station", timevar="Date", idvar=c("Value"), direction="wide")
What I am doing wrong?