dear R wizards: I am wrestling with reshape. I have a long data set that I want to convert into a wide data set, in which rows are firms and columns are years.
> summary(rin) firm fyear sim1 Min. :1004.00 Min. :1964.0 Min. : -1.00000 1st Qu.:1010.00 1st Qu.:1979.0 1st Qu.: -0.14334 Median :1016.00 Median :1986.0 Median : 0.00116 Mean :1016.34 Mean :1986.1 Mean : 1.03475 3rd Qu.:1021.00 3rd Qu.:1993.2 3rd Qu.: 0.26931 Max. :1034.00 Max. :2007.0 Max. :110.66860 S.D. : 9.26 S.D. : 10.0 S.D. : 8.37811 T-stat :1551.59 T-stat :2804.7 T-stat : 1.69344 Obs. : 200.00 Obs. : 200.0 Obs. :188.00000 NA's : 12.00000 the firms and years are both ordered. I tried reshape(rin, timevar="fyear", idvar="gvkey", direction="wide"), and the shape seems to be what I want, but the columns come out in random order (sim1.1980, then sim1.2001, then sim1.1977) and so on. I would like years to go from left to right, too. Is there an easy way to accomplish this? sincerely, /iaw ---- Ivo Welch (ivo.we...@brown.edu, ivo.we...@gmail.com) ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.