[R] Convert a list in a dataframe

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Oct 22 14:09:47 CEST 2004


Vito Ricci <vito_ricci at yahoo.com> writes:

> Hi,
> 
> I've a list containing parameters (intercepts &
> coefficients) of 12 regressions fitted
> 
> > coeff
> [[1]]
>  (Intercept)         anno 
> -427017.1740     217.0588 
> 
> [[2]]
>  (Intercept)         anno 
> -39625.82146     21.78025 
> 
> .....
> 
> [[12]]
> (Intercept)        anno 
> 257605.0343   -129.7646 
> 
> I want create a data frame with two columns (intercept
> and anno)using data in these list.

data.frame(do.call("rbind",coeff))

Did this result from an lapply() construct? If so, consider using
sapply(); then you can just do

data.frame(t(coeff))

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list