How to specify names of columns for x and y when joining in dplyr?

前端 未结 2 1727
心在旅途
心在旅途 2020-12-22 20:40

I have two data frames that I want to join using dplyr. One is a data frame containing first names.

test_data <- data.frame(first_name = c(\"john\", \"bil         


        
2条回答
  •  别那么骄傲
    2020-12-22 21:29

    This feature has been added in dplyr v0.3. You can now pass a named character vector to the by argument in left_join (and other joining functions) to specify which columns to join on in each data frame. With the example given in the original question, the code would be:

    left_join(test_data, kantrowitz, by = c("first_name" = "name"))
    

提交回复
热议问题