Skip to content
Prev 131072 / 398506 Next

How to cbind DF:s with differing number of rows?

Hi Lauri,

I see two possibilities.

Let say that you have
a <-c(1:5)
b <- c(1:7)
c <- c(1:4)
l <- list(a,b,c)

and you want to create an Excel file with columnA (1)
containing a (5 rows), column B (2) containing b and
column C containing c.

One possibility would be to write each ROW of the
output file separately (7 rows in your case) writing
nothing (just \t ) when you reach the end of the
particular item in the list. 

Another possibility would be to use xlsReadWritePro
package which allows to write each item (a,b,c) (or
list element - l[[1]],l[[2]],... etc) to a given
column of the output file.

Regards,

Moshe.
--- Lauri Nikkinen <lauri.nikkinen at iki.fi> wrote: