我有一个结构如下的数据帧:
variable_1<-rep("one",times=8)
variable_2<-c("one","one","two","two","three","three","four","four")
actual<-c(0,10,0,20,0,30,0,40)
predicted<-c(10,0,20,0,30,0,40,0)
data_1<-data.frame(cbind(variable_1,variable_2,actual,predicted))
我想对列进行移位,以获得具有以下结构的数据帧:
variable_1_new<-rep("one",times=4)
variable_2_new<-c("one","two","three","four")
actual_new<-c(10,20,30,40)
predicted_new<-c(10,20,30,40)
data_2<-data.frame(cbind(variable_1_new,variable_2_new,actual_new,predicted_new))
任何帮助都将不胜感激。
https://stackoverflow.com/questions/52543332
复制相似问题