[R] match in dependence of 2 columns
Rui Barradas
ruipbarradas at sapo.pt
Wed Feb 13 17:17:50 CET 2013
Hello,
Try the following.
data.frame1 <- read.table(text = "
cu.nr. name value
A 1 Evo 100
B 1 Mer 80
C 2 Ford 50
", header = TRUE)
data.frame2 <- read.table(text = "
cu.nr. name
A 33 Evo
B 1 Mer
C 1 Pold
", header = TRUE)
merge(data.frame2, data.frame1, all.x = TRUE)
Hope this helps,
Rui Barradas
Em 13-02-2013 14:39, Mat escreveu:
> Hello,
>
> i want to match a column of one data.frame to another, my problem is, that i
> only want to match the data, if 2 columns are equal.
>
> i have a example:
>
> data.frame1
> cu.nr. name value
> A 1 Evo 100
> B 1 Mer 80
> C 2 Ford 50
>
> And now i want to match the value to data.frame 2 in dependence of cu.nr.
> and name.
>
> data.frame2
> cu.nr. name
> A 33 Evo
> B 1 Mer
> C 1 Pold
>
> as you can see, there is only one row with equal cu.nr. and name. How can i
> match the data as desired?
> The solution has to look like this one:
>
> cu.nr. name Value
> A 33 Evo
> B 1 Mer 80
> C 1 Pold
>
> thanks.
>
> Mat
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/match-in-dependence-of-2-columns-tp4658405.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list