Why am I getting this error while merging two dataframes?

B

B_man

Guest
I am trying to merge two data frames by column names called "teams".

My merge statement-

merge(RB,LB,by.x ="team")


The error I am getting is-

Error in merge.data.frame(RB, LB, by.x = "team") : 'by.x' and 'by.y' specify different numbers of columns.
#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
)

Continue reading...
 
Top