[R] splitting a long dataframe
Swagath
swagathnavin82 at gmail.com
Tue Dec 25 18:52:47 CET 2012
Dear all...Merry Christmas
I would like to split a long dataframe. The dataframe looks like this
x<-c('0:00:00', '0:30:00', '1:00:00', '1:30:00', '2:00:00', '2:30:00',
'3:00:00', '0:00:00', '0:30:00', '1:00:00', '1:30:00', '2:00:00',
'2:30:00', '3:00:00', '3:30:00', '4:00:00','0:00:00', '0:30:00',
'1:00:00', '1:30:00', '2:00:00', '2:30:00', '3:00:00', '0:00:00',
'0:30:00', '1:00:00', '1:30:00', '2:00:00', '2:30:00', '3:00:00' ,
'3:30:00', '4:00:00')
y=seq(1:32)
data1=data.frame(x,y)
i want to split in such a way that the output looks like
0:00:00 1 8 17 24
0:30:00 2 9 18 25
1:00:00 3 10 19 26
1:30:00 4 11 20 27
2:00:00 5 12 21 28
2:30:00 6 13 22 29
3:00:00 7 14 23 30
3:30:00 NA 15 NA 31
4:00:00 NA 16 NA 32
any ideas or functions that i look into for doing this?
Thanks a lot for your help and time.
Cheers,
Swagath
More information about the R-help
mailing list