No, I don't think so. rbind
requires the same number of columns in each matrix or data frame. From the help page:
If there are several matrix arguments, they must all have the same
number of columns (or rows) and this will be the number of columns
(or rows) of the result. If all the arguments are vectors, the
number of columns (rows) in the result is equal to the length of
the longest vector. Values in shorter arguments are recycled to
achieve this length (with a ‘warning’ if they are recycled only
_fractionally_).
And proof:
> a <- rnorm(3)
> b <- rnorm(3)
> c <- rnorm(3)
> df.one <- data.frame(a, b, c)
> df.two <- data.frame(a, b)
> rbind(df.one, df.two)
Error in rbind(deparse.level, ...) :
numbers of columns of arguments do not match
But you can do a hackish recycling of the smaller data frame and rename the columns:
> df.three <- cbind(df.two, df.two[, 1:(ncol(df.one) - ncol(df.two))])
> colnames(df.three) <- colnames(df.one)
> rbind(df.one, df.three)
a b c
1 -2.499236596 0.08539973 0.070122711
2 -1.304782366 0.44049636 -0.848588975
3 0.005446522 0.36805686 -0.251105213
4 -2.499236596 0.08539973 -2.499236596
5 -1.304782366 0.44049636 -1.304782366
6 0.005446522 0.36805686 0.005446522
Darn it! Beat by Dirk! Maybe this recycling will help anyways...