Re: [R] turn list into dataframe

2012-10-09 Thread Benjamin Caldwell
;-function(y,len){ >> > c(y,rep(NA,len-length(y))) >> > } >> > maxlen<-max(sapply(x,length)) >> > do.call(data.frame,lapply(x,na.pad,len=maxlen)) >> > } >> > fun1(list1) >> > A.K. >> > >> > >> > >>

Re: [R] turn list into dataframe

2012-10-09 Thread R. Michael Weylandt
; na.pad<-function(y,len){ > > c(y,rep(NA,len-length(y))) > > } > > maxlen<-max(sapply(x,length)) > > do.call(data.frame,lapply(x,na.pad,len=maxlen)) > > } > > fun1(list1) > > A.K. > > > > > > > > > > > > >

Re: [R] turn list into dataframe

2012-10-09 Thread Benjamin Caldwell
;) > > fun1<-function(x){ > na.pad<-function(y,len){ > c(y,rep(NA,len-length(y))) > } > maxlen<-max(sapply(x,length)) > do.call(data.frame,lapply(x,na.pad,len=maxlen)) > } > fun1(list1) > A.K. > > > > > > > > - Original Messa

Re: [R] turn list into dataframe

2012-10-09 Thread arun
, 7.5141,  :   #arguments imply differing number of rows: 8, 14 That was the reason I used the function. A.K.   - Original Message - From: Purna chander To: arun Cc: Sent: Tuesday, October 9, 2012 1:52 AM Subject: Re: [R] turn list into dataframe Hi Ben, try this.. as.da

Re: [R] turn list into dataframe

2012-10-08 Thread arun
(x){  na.pad<-function(y,len){  c(y,rep(NA,len-length(y)))  }  maxlen<-max(sapply(x,length))  do.call(data.frame,lapply(x,na.pad,len=maxlen))  }  fun1(list1) A.K. - Original Message - From: Benjamin Caldwell To: r-help Cc: Sent: Monday, October 8, 2012 5:49 PM Subject: [R]

Re: [R] turn list into dataframe

2012-10-08 Thread R. Michael Weylandt
On Mon, Oct 8, 2012 at 10:49 PM, Benjamin Caldwell wrote: > Dear R users, > > I'm starting to use 'apply' functions rather than for loops in R, and > sometimes the output is a bit different than what I want. In this case, the > command was > > > tapply(myvector,myindex,cumsum) > > And the output w

[R] turn list into dataframe

2012-10-08 Thread Benjamin Caldwell
Dear R users, I'm starting to use 'apply' functions rather than for loops in R, and sometimes the output is a bit different than what I want. In this case, the command was tapply(myvector,myindex,cumsum) And the output was something like this: $`SNRL1 Core 120` [1] 2.8546 4.0778 5.2983 6.3