Is there any way I can use a character vector in the 'by' argument of a left_Join in R
I'm trying the following:
DF <- data.frame(a = c("q","a","a","b","b","b","c","c","c","c"), b = c("w","e","r","t","y","u","i","i","w","f"))
DF2 <- data.frame(aa = c("q","a","b","c"), cc = c(1,2,3,4))
DFNames <- names(DF)
left_join(DF,DF2, by = c(DFNames[1] = "aa"))
But I get
Error: unexpected '=' in "left_join(DF,DF2, by = c(DFNames[1] ="
the issue definitely stems from c(DFNames[1] = "aa")
Which returns:
Error: unexpected '=' in "c(DFNames[1] ="
Cheers!