[R] correct subset in R
ruipbarradas at sapo.pt
Thu Mar 23 19:28:39 CET 2017
I would try ?merge, in particular see the arguments by.x and by.y
Hope this helps,
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!
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help