【发布时间】:2021-07-27 17:06:39
【问题描述】:
我有两个数据框,一个包含各个国家/地区的经济信息,另一个包含国家/地区的专有名称。两个数据框如下所示:
country <- c("Afghanistan", "Afghanistan", "United States", "United States", "Congo, Dem. Rep.", "Congo, Dem. Rep.", "Middle East and North Africa", "Middle East and North Africa")
years <- c(2011, 2012, 2011, 2012, 2011, 2012, 2011, 2012)
gdp <- c(123, 442, 9451, 9999, 351, 664, 7531, 6634)
economic_data <- cbind.data.frame(country, years, gdp)
country_proper <- c("Afghanistan", "United States of America", "Congo DR")
我想将economic_data 中的国家名称更改为country_proper 数据中的专有名称,然后删除经济数据中没有出现在country_proper 中的国家(如“中东和北非”)。
【问题讨论】: