Hello, I would try ?merge, in particular see the arguments by.x and by.y
Hope this helps, Rui Barradas Em 23-03-2017 18:19, Elahe chalabi via R-help escreveu:
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 ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.