How to create a vector indicating matches between the elements of one vector and any element in another?

后端 未结 1 1653
野性不改
野性不改 2020-12-22 03:08

I am trying to create a vector indicating whether country names in a data frame match any value from a separate list.

The separate list of country names looks like t

相关标签:
1条回答
  • 2020-12-22 04:13

    How about

    transform(df,match=as.numeric(country %in% list))
    

    ?

    (I can't help pointing out that the %in% operator is covered on the R help page for the "match" function ...)

    0 讨论(0)
提交回复
热议问题