[R] intersect of 2 data frames
Dimitris.Rizopoulos at med.kuleuven.be
Sun May 6 21:33:51 CEST 2007
look at ?merge(), e.g., try something like the following:
merge(pretestm, posttest, by = "StuNum")
check also the on-line help page for more info, especially for the
I hope it helps.
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Quoting Salvatore Enrico Indiogine <hindiogine at gmail.com>:
> I am a new user of R. The only one in my department, all others use SPSS.
> I have two data sets of students with test scores, pretest and
> posttest. The first column StuNum and then columns of scores.
> The problem is that the lists are slightly different not all students
> are in both data sets.
> So I did:
> intersect(pretest$StuNum, posttest$StuNum) -> common.id
> At this point I need to select from pretest the students in common.id
> and do the same with posttest.
> I have tried several things but, basically I do not know how to do so.
> In SQL it should be something like:
> select pretest$StuNum in common.id
> Any pointers?
> Enrico Indiogine
> Mathematics Education
> Texas A&M University
> hindiogine at gmail.com
> R-help at stat.math.ethz.ch mailing list
> 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