[BioC] Saving list as tab del file

Seth Falcon sfalcon at fhcrc.org
Thu Aug 10 17:11:25 CEST 2006


Marco Blanchette <mblanche at berkeley.edu> writes:
> Dear all,
>
> Again, I have one more question that will sound very basic to you R
> aficionados.

Consider sending this sort of question to R-help as it has nothing
BioC specific...

> I have a list of several columns containing different number of items as in:
>
> aList = list(C1=c(1:10), C2=c(15:35))

Are all elements the same length?  If not, is the assumption that you
want to pad the end of short vectors with NA?

We'll use a helper from Biobase to make this BioC specific ;-)

library("Biobase")
length(unique(listLen(aList))) == 1

You could make a matrix like this:

  mat <- do.call(cbind, aList)
  write.table(mat)

If lengths are not equal...

lens <- listLen(aList)
nRows <- max(lens)
bList <- lapply(aList, function(x) {
    if (length(x) != nRows)
        c(x, rep(NA, nRows - length(x)))
    else
        x
})


+ seth



More information about the Bioconductor mailing list