Hi: Thanks, David and Thierry. I knew what I did was inefficient, but I'm not very adept with cast() yet. Thanks for the lesson! The time is less than half without the fun = mean statement, too. On my system, the timing of David's call was 2.06 s elapsed; with Thierry's, it was 4.88 s. Both big improvements over my band-aid attempt.
Regards, Dennis On Thu, Sep 2, 2010 at 3:36 AM, carslaw <david.cars...@kcl.ac.uk> wrote: > > picking up on Thierry's example, I don't think you need any function > because > you are just reshaping > (not aggregating). Therefore: > > bigtab2 <- cast(data = big, study + subject + cycle + day ~type, value = > "obs") > > head(bigtab2) > study subject cycle day ALB ALP ALT AST > 1 1 1 1 1 66 71 83 76 > 2 1 1 1 2 66 87 78 58 > 3 1 1 1 3 72 84 78 61 > 4 1 1 1 4 72 63 68 69 > 5 1 1 1 5 64 68 89 89 > 6 1 1 2 1 78 65 65 76 > > system.time(bigtab2 <- cast(data = big, study + subject + cycle + day > ~type, value = "obs")) > user system elapsed > 0.760 0.000 0.782 > > david > -- > View this message in context: > http://r.789695.n4.nabble.com/reshape-to-wide-format-takes-extremely-long-tp2487153p2506575.html > Sent from the R help mailing list archive at Nabble.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. > [[alternative HTML version deleted]] ______________________________________________ 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.