[R] reshape to wide format takes extremely long

2010-09-02 Thread Coen van Hasselt
Hello, I have a data.frame with the following format: head(clin2) Study Subject Type Obs Cycle Day Date Time 1 A001101 10108 ALB 44.098 1 2004-03-11 14:26 2 A001101 10108 ALP 95.098 1 2004-03-11 14:26 3 A001101 10108 ALT 61.098 1

Re: [R] reshape to wide format takes extremely long

2010-09-02 Thread Dennis Murphy
Hi: I did the following test using function ddply() in the plyr package on a toy data frame with 5 observations using five studies, 20 subjects per study, 25 cycles per subject, five days per cycle and four observations by type per day. No date-time variable was included. # Test data frame

Re: [R] reshape to wide format takes extremely long

2010-09-02 Thread ONKELINX, Thierry
-project.org Onderwerp: Re: [R] reshape to wide format takes extremely long Hi: I did the following test using function ddply() in the plyr package on a toy data frame with 5 observations using five studies, 20 subjects per study, 25 cycles per subject, five days per cycle and four

Re: [R] reshape to wide format takes extremely long

2010-09-02 Thread carslaw
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

Re: [R] reshape to wide format takes extremely long

2010-09-02 Thread Dennis Murphy
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