Did you consider to look at the help page for merge?
h
At 22:01 13.01.2010, karena wrote:
hi, I have a question about merging two files.
For example, I have two files, the first file is like the following:
id trait1
1 10.2
2 11.1
3 9.7
6 10.2
7 8.9
10 9.7
11 10.2
The second file is like the following:
id trait2
1 9.8
2 10.8
4 7.8
5 9.8
6 10.1
12 10.2
13 10.1
now I want to merge the two files by the variable "id", I only want to keep
the "id"s which show up in the first file. Even the "id" does not show up in
the second file, it doesn't matter, I can keep the missing values. So my
question is: how can I merge the two files and keep only the rows whose "id"
show up in the first file?
I know how to do it is SAS, just use the following code:
merge data1(in=in1) data2(in=in2);
by id;
if in1;
but I really have no idea about how to do it in R.
thank you in advance,
karean
--
View this message in context:
http://n4.nabble.com/merging-issue-tp1013356p1013356.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@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.
______________________________________________
R-help@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.