On 11/7/06, Denis Chabot <[EMAIL PROTECTED]> wrote:
> Dear list members,
>
> I have to combine dataframes together. However they contain different
> numbers of variables. It is possible that all the variables in the
> dataframe with fewer variables are contained in the dataframe with
> more variables, though it is not always the case.
>
> There are key variables identifying observations. These could be used
> in a merge statement, although this won't quite work for me (see below).
>
> I was hoping to find a way to combine dataframes where I needed only
> to ensure the key variables were present. The total number of
> variables in the final dataframe would be the total number of
> different variables in both initial dataframes. Variables that were
> absent in one dataframe would automatically get missing values in the
> joint dataframe.

Have a look at rbind.fill in the reshape package.

library(reshape)
rbind.fill(data.frame(a=1), data.frame(b=2))
rbind.fill(data.frame(a=1), data.frame(a=2, b=2))


Hadley

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to