[R] Correct subsetting in R

Elahe chalabi chalabi.elahe at yahoo.de
Wed Nov 1 17:13:42 CET 2017


Hi all,
I have two data frames that one of them does not have the column ID:

    > str(data)
    'data.frame':	499 obs. of  608 variables:
    $ ID           : int  1 2 3 4 5 6 7 8 9 10 ...
    $ alright      : int  1 0 0 0 0 0 0 1 2 1 ...
    $ bad          : int  1 0 0 0 0 0 0 0 0 0 ...
    $ boy          : int  1 2 1 1 0 2 2 4 2 1 ...
    $ cooki        : int  1 2 2 1 0 1 1 4 2 3 ...
    $ curtain      : int  1 0 0 0 0 2 0 2 0 0 ...
    $ dish         : int  2 1 0 1 0 0 1 2 2 2 ...
    $ doesnt       : int  1 0 0 0 0 0 0 0 1 0 ...
    $ dont         : int  2 1 4 2 0 0 2 1 2 0 ...
    $ fall         : int  3 1 0 0 1 0 1 2 3 2 ...
    $ fell         : int  1 0 0 0 0 0 0 0 0 0 ...

and the other one is:

    > str(training)
    'data.frame':	375 obs. of  607 variables:
    $ alright      : num  1 0 0 0 1 2 1 0 0 0 ...
    $ bad          : num  1 0 0 0 0 0 0 0 0 0 ...
    $ boy          : num  1 1 2 2 4 2 1 0 1 0 ...
    $ cooki        : num  1 1 1 1 4 2 3 1 2 2 ...
    $ curtain      : num  1 0 2 0 2 0 0 0 0 0 ...
    $ dish         : num  2 1 0 1 2 2 2 1 4 1 ...
    $ doesnt       : num  1 0 0 0 0 1 0 0 0 0 ...
    $ dont         : num  2 2 0 2 1 2 0 0 1 0 ...
    $ fall         : num  3 0 0 1 2 3 2 0 2 0 ...
    $ fell         : num  1 0 0 0 0 0 0 0 0 0 ...
Does anyone know how should I get the IDs of training from data?
thanks for any help!
Elahe



More information about the R-help mailing list