[R] converting lists got by tapply to dataframes

kjetil@entelnet.bo kjetil at entelnet.bo
Wed Mar 10 18:02:49 CET 2004


On 10 Mar 2004 at 15:58, Wolfram Fischer wrote:

It's a bit strange. The following should work:

as.data.frame(as.matrix(xb))

Kjetil Halvorsen


> I have two lists:
> 
>     xa <- list( X=c(1,2,3), Y=c(4,5,6), Z=c(7,8,9) )
> 
>     xb <- with( barley, tapply( X=seq(1:nrow(barley)), INDEX=site
>         , FUN=function(z)yield[z]))
> 
> I can convert xa to a dataframe easily with:
>     as.data.frame(xa)
> 
> But if i try the same with xb I get:
>     as.data.frame(xb)
>     Error in as.data.frame.default(xb) :
>     can't coerce array into a data.frame
> 
> What helps?
> 
> (NB: I know the formula for xb is stupid, but it generates the same
> type of list as the list I get from my real problem.)
> 
> Wolfram
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html




More information about the R-help mailing list