[R] converting a list to a data.frame

2007-04-03 Thread Biscarini, Filippo
Hello, I have a list with n numerical components of different length (3, 4 or 5 values in each component of the list); I need to export this as a text file where each component of the list will be a row and where missing values should fill in the blanks due to the different lengths of the compone

Re: [R] converting a list to a data.frame

2007-04-03 Thread Mark Wardle
Biscarini, Filippo wrote: > Dear Mark, > > If you have time you can try directly into R this excerpt from my list. > This is horrible code, and I should be shot! I would appreciate any better ways of doing this, but I think this works! l = list(c(1,2,4),c(4,5,2,1),c(3,4,6,3),c(3,1,76,4,2)) f

Re: [R] converting a list to a data.frame

2007-04-03 Thread Dimitris Rizopoulos
dimitris.htm - Original Message - From: "Biscarini, Filippo" <[EMAIL PROTECTED]> To: Sent: Tuesday, April 03, 2007 11:28 AM Subject: [R] converting a list to a data.frame > Hello, > > I have a list with n numerical components of different length (3, 4 > or

Re: [R] converting a list to a data.frame

2007-04-03 Thread Stephen Tucker
You can concatenate a series of NA's to match the length of your longest element. (1) exampDat is example data (2) max(rapply(exampDat,length)) is length of longest element (3) function(x,m) will do the concatenation (4) sapply() will return each list element as a column of a data frame (5) t() wi

Re: [R] converting a list to a data.frame

2007-04-03 Thread Patrick Connolly
On Tue, 03-Apr-2007 at 01:55PM +0200, Dimitris Rizopoulos wrote: |> try something like this: |> |> lis <- list(c(1,2,4), c(4,5,2,1), c(3,4,6,3), c(3,1,76,4,2)) |> ## |> n.max <- max(sapply(lis, length)) |> val <- NA # what to fill in |> fill <- function(x) c(x, rep(val, n.max - length(x))