;-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.
>> >
>> >
>> >
>>
; 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.
> >
> >
> >
> >
> >
> >
>
;)
>
> 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
, 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
(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]
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
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
7 matches
Mail list logo