[R] intersect of 2 data frames
Dimitris Rizopoulos
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
'all' argument.
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
Quoting Salvatore Enrico Indiogine <hindiogine at gmail.com>:
> Greetings!
>
> 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?
>
> Thanks,
> Enrico
>
>
> --
> Enrico Indiogine
>
> Mathematics Education
> Texas A&M University
> hindiogine at gmail.com
>
> ______________________________________________
> R-help at 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.
>
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the R-help
mailing list