Re: [R] Reshape to wide format

2016-12-28 Thread David L Carlson
     NA 10    10      0.000             NA 11    11      0.1215360             NA 12    12      0.3886606             NA - David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help

Re: [R] Reshape to wide format

2016-12-22 Thread Miluji Sb
129 > 9 9 0.000 NA > 1010 0.000 NA > 1111 0.1215360 NA > 1212 0.3886606 NA > > - > David L Carlson > Department of Anthropology > Texas A&M U

Re: [R] Reshape to wide format

2016-12-13 Thread David L Carlson
tment of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon Sent: Tuesday, December 13, 2016 2:59 AM To: Miluji Sb; r-help mailing list Subject: Re: [R] Reshape to wide format Hi

Re: [R] Reshape to wide format

2016-12-13 Thread Jim Lemon
Hi Milu, I may have the wrong idea, but is this what you want? temp$ID<-paste(temp$iso3,temp$lon,temp$lat,sep="") library(prettyR) newtemp<-stretch_df(temp,"month","precip")[,c(5,7,8)] names(newtemp)<-c("month",unique(temp$ID)) Jim On Tue, Dec 13, 2016 at 4:10 AM, Miluji Sb wrote: > Dear all,

Re: [R] Reshape to wide format

2016-12-12 Thread Subodh Adhikari
For long to wide, try *dcas*t function in reshape2 package. (*melt* is from wide to long). Subodh On Mon, Dec 12, 2016 at 10:10 AM, Miluji Sb wrote: > [image: Boxbe] Miluji Sb ( > miluj...@gmail.com) is not on your Guest List >

[R] Reshape to wide format

2016-12-12 Thread Miluji Sb
Dear all, I have the following monthly data by coordinates: I would like to reshape this data to wide format so that each column is a coordinate and each row is a month, coordinate1 coordinate2 coordinate3... Month 1 Month 2 Is the best option to concatenate the iso3, lon, and lat variables to

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 im

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

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

2010-09-02 Thread ONKELINX, Thierry
er 2010 11:34 > Aan: Coen van Hasselt > CC: r-help@r-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 st

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 bi

[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 2004-0