基于该行中的名称,将变量添加到特定行中的dataframe中
我试图在这个地图数据框中添加与特定国家相对应的特定变量基于该行中的名称,将变量添加到特定行中的dataframe中,r,dataframe,append,R,Dataframe,Append,我试图在这个地图数据框中添加与特定国家相对应的特定变量 library(maps) countries <- c("Australia", "South Africa", "India", "Mexico", "USA", "Russia") genes <- c("gene1","gene2","gene3","gene4","gene5","gene6") bounds <- map("world", countries, fill = TRUE, plot = FAL
library(maps)
countries <- c("Australia", "South Africa", "India", "Mexico", "USA", "Russia")
genes <- c("gene1","gene2","gene3","gene4","gene5","gene6")
bounds <- map("world", countries, fill = TRUE, plot = FALSE)
bounds$genes <- genes
库(地图)
国家你可以这样做
bounds$genes <- genes[match(gsub("\\:.*", "", bounds$names), countries)]
bounds$genes是的,这确实有效,非常感谢,这是一个简单的解决方案!