Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于该行中的名称,将变量添加到特定行中的dataframe中_R_Dataframe_Append - Fatal编程技术网

基于该行中的名称,将变量添加到特定行中的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是的,这确实有效,非常感谢,这是一个简单的解决方案!