Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对R比较陌生,我认为这可能是一件简单的事情,但我不知道怎么做!到目前为止,我在我的 shapefilewrld_simpl$NAME的列和我的数据集中的一列中找到了哪些国家名称匹配,我已经这样做了:species$Country
wrld_simpl$NAME
species$Country
wrld_simpl$NAME %in% species$Country
它返回一个 TRUE/FALSE 值的向量,但我想返回一个在两个数据集中都可以找到的国家名称的向量。
也许这会有所帮助:
A <-c("Austria", "Germany", "Italy", "USA") B <-c("Austria", "Italy", "USA") intersect(A, B) #[1] "Austria" "Italy" "USA"
hth
改用这个:
which(wrld_simpl$NAME %in% species$Country)
这将为您提供索引。