I would like to move a data.frame from long to wide. Whenever I have a duplicate id, I want to copy my results in a particular var to a new col. In the end I want id to be a unique id. I have looked at using the reshape function - but can't seem how to handle not having the "timevar" - in my particular case, I don't have a grouping var that I want to reshape based on. There is a ton on stack overflow with reshaping data but I can't seem to find this issue.
I have:
a<-
data.frame(
id = c( 11,12,13,14,15,15,16,17,17,18,19,10) ,
pi = c( 21:32 )
)
I want
b<-
data.frame(
id = c( 11,12,13,14,15,16,17,18,19,10) ,
pi = c( 21:25,27:28,30:32 ),
pi2 = c( NA,NA,NA,NA,26,NA,29,NA,NA,NA)
)