我正在尝试按名为“团队”的列名称合并两个数据框。
我的合并声明-
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)