Hi Jim,
Thanks again. Actually i changed my code where the lists are not
nested. Your code works, as you said for the example, but still is not
working for my lists (30). My lists have different columns and rows
and several are NULL; plus there are many blank space which i suppose
don't make much
I tried Jim's function and it works. But here is an example just in case.
AA <- list(a=c(1,2,3,4),b = c("a","b","c"))
BB <- list(c=c(1,2,3,4,5),d=c("a","b","c","d","e"))
mylist <- (list(AA,BB))
lapply(mylist,function(x) write.table(x,file = test.txt))
Show Traceback
Error in (function (..., ro
Hi Ek,
I thought there would be a simple fix for this, but had to write a
little function:
fillList<-function(x) {
maxrows<-max(unlist(lapply(x,length)))
return(lapply(x,"[",1:maxrows))
}
that fills up the rows of each list with NAs. I got the expected result with:
testlist<-list(a=1:8,b=1:9,c
FWIW, I had no trouble writing a test case to a file with either version of
your code. As we have no idea what your data look like, I don't know how
anyone can diagnose the problem. But maybe I'm wrong and someone else will
recognize the issue.
Cheers,
Bert
Bert Gunter
"The trouble with having a
Hi All,
I have an R object that is made up of N number of lists which are all
of different number of columns and rows. I want to combine the N
lists into a single data frame or write (append) them into text file.
I hope the question is clear and doesn’t require an example. I am
hoping to accompli
5 matches
Mail list logo