[R] merging data.frames of different length
David Winsemius
dwinsemius at comcast.net
Thu Jun 18 02:42:32 CEST 2009
Red the help page for merge:
?merge
On Jun 17, 2009, at 8:33 PM, Martin Batholdy wrote:
> hi,
>
>
> I have two data.frames each with two columns;
>
>
> x1
>
> 1 4
> 1 3
> 1 6
> 2 9
> 2 2
> 2 5
> 3 6
> 3 7
> 3 4
>
>
> x2
>
> 1 -3
> 1 -7
> 2 -3
> 2 -2
> 2 -8
> 3 -1
> 3 -2
> 3 -1
>
> now I want to merge this data.frames to one data.frame.
>
> The problem is, that sometimes there is a different number of
> elements per category.
> (like above x1 has 3 values for the value 1 in the first row, but x2
> has only 2 values for the value 1 in the first row).
>
> Is there an easy way to merge this two data.frames by deleting the
> rows that only one data.frame "has".
> In the example, that resulting data.frame would be the data.frame x1
> and x2 except the row 3 of data.frame x1.
>
> thanks for any suggestions!
>
> ______________________________________________
> R-help at r-project.org 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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list