On Jul 7, 2011, at 4:40 PM, Shant Ch wrote:

Hello R users,

I have two data sets like the following. Form of dataset:

data:

     X1       X2        X3    X4       X5
    1902       RE        3      594        9
     1903       RE        3     1340        7
     1904       AA        3      760       14
     1908       RE        4     1759       18
     1909       EX        2      387        1
     2901       AU        6     3116        2
     3801       AA        1      304       29
   3902       RE        5     2482        6

I need to select rows of a data set based on the common observations of X1. Using intersect command I got the common observations of X1 from the two data
sets as:

common=c(1902, 1904, 1908, 1909, 3801).

Using subset command I can select portions separately. But in general if I am given this type of dataset - "data" with large number of rows and also a list of X1 - "common" containing many elements, can anyone please let me know how to
select portion of the data whose X1 values are same as common values.

subset(dfrm, x1 %in% common)

?subset


If any questions let me know.

Shant.
        [[alternative HTML version deleted]]

______________________________________________
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.

David Winsemius, MD
West Hartford, CT

______________________________________________
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.

Reply via email to