小编B_m*_*man的帖子

为什么在合并两个数据帧时会出现此错误?

我正在尝试按名为“团队”的列名称合并两个数据框。

我的合并声明-

merge(RB,LB,by.x ="team")
Run Code Online (Sandbox Code Playgroud)

我收到的错误是-

merge.data.frame(RB, LB, by.x = "team") 中的错误:“by.x”和“by.y”指定了不同的列数。

#Create a data frame to store set of Right-Backs
      RB=data.frame(
       team=c("Liverpool",
     "Manchester United",
     "Chelsea","Atletico Madrid",
     "Juventus",
     "Real Madrid"),
     players=c("Trent-Alexandre Arnold",
        "Diogo Dalot",
        "Cesar Azpilicueta",
        "Keiran Trippier",
        "Danilo","Carvajal")
      ,stringsAsFactors = FALSE)

   #Create a data frame to store set of Left-Backs
    LB=data.frame(
    team=c("Manchester United",
     "Real Madrid",
     "Liverpool",
     "Chelsea",
     "Juventus",
     "Atletico Madrid"
     ),
     players=c("Luke Shaw","Marcelo","Andrew Robertson","Marcos Alonso","Alex Sandro", "Renan Lodi" ),
    stringsAsFactors = FALSE
     )
Run Code Online (Sandbox Code Playgroud)

merge r dataframe

1
推荐指数
1
解决办法
3161
查看次数

标签 统计

dataframe ×1

merge ×1

r ×1