【发布时间】:2019-04-30 15:38:00
【问题描述】:
我有两个小标题,一个带有一些长度不均匀的系列代码,一个带有国家/地区代码
codes <- as.tibble(c("brcomec", "frcomopf", "decombwf", "ezcomop",
"jpcomop", "aewheob", "ezcompis", "decomipf"))
countries <- as.tibble(c("br", "fr", "advecos", "af", "africa", "al", "dz", "as", "ad",
"ao", "ai", "aq", "ag"))
根据国家/地区的信息,我如何从“代码”中提取国家/地区,即我希望有类似的东西
dta <- data.frame(
~country , ~ rest ,
br , comec ,
fr , comopf ,
...
)
我尝试使用 filter(str_detect(code, paste(countries))) 但这没有成功,因此非常感谢任何帮助。
【问题讨论】:
标签: r filter dplyr tidyverse stringr