[R] correct subset in R

Elahe chalabi chalabi.elahe at yahoo.de
Thu Mar 23 19:19:31 CET 2017


Hi all,
I found an answer to the last question I asked in this group and now I want to have a correct subset of my data:

I have a following df1 which is list of all cities in US and their states:

$ name         : Factor w/ 1008 levels "Ackley","Ackworth",..: 1 2 3 
$ state        : Factor w/ 1 level "Iowa": 1 1 1 1 1 1 1 1 1 1 .

the other data frame I have is df2 which is the list of cities I have and I want to get their state from df1:

$ cities : Factor w/ 547 levels "Afton","Boone","Calmar",...: 1 2 3 


now how should I subset in a way to get related states of $cities from df1?

Thanks for any help!
Elahe



More information about the R-help mailing list