问题
I would like to reshaping some rows of my database. In particular I have some row that it replicate for the Id column. I would like to convert this row in column. I provide a code that it represent a example of my database. I'm trying with t() and reshape but it doesn't do that I would. Can anyone give me any suggestions?
test<-data.frame(Id=c(1,1,2,3),
St=c(20,80,80,20),
gap=seq(0.02,0.08,by=0.02),
gip=c(0.23,0.60,0.86,2.09),
gat=c(0.0107,0.989,0.337,0.663))
回答1:
setNames(data.frame(t(test))[2:nrow(data.frame(t(test))),], test$Id)
1 1 2 3
St 20.0000 80.000 80.000 20.000
gap 0.0200 0.040 0.060 0.080
gip 0.2300 0.600 0.860 2.090
gat 0.0107 0.989 0.337 0.663
It helps to provide an expected output. It this what you expected?
来源:https://stackoverflow.com/questions/56394091/reshaping-database-using-reshape-package