Skip to content
Prev 277904 / 398506 Next

reshape data.frame

You can use the reshape() in core R (the stats package)
name amount.1971 amount.1972 amount.1973 amount.1974
1     a           1           2           3           4
11    b          11          12          13          14
   amount.1975 amount.1976 amount.1977 amount.1978
1            5           6           7           8
11          15          16          17          18
   amount.1979 amount.1980 amount.1981 amount.1982
1            9          10          NA          NA
11          19          20          21          22
   amount.1983 amount.1984 amount.1985
1           NA          NA          NA
11          23          24          25

(Was naming the output columns "X.<year>" instead of "amount.<year>"
important?)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com