You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inconsistency with left_join()'s by= argument, variable quotes are inconsistently parsed when matching different variables between first and second tibble. Quotes on first key don't matter, but the second key must be quoted.
## version R version 3.4.3 (2017-11-30)## dplyr * 0.7.4 2017-09-28 CRAN (R 3.4.2)
library(tidyverse)
df1<- tibble(key1= c(1, 2, 3), val1= c(letters[key1]))
df2<- tibble(key2= c(1, 2, 4), val2= c(letters[key2]))
# quote bothdf1 %>% left_join(df2, by= c("key1"="key2"))
# quote seconddf1 %>% left_join(df2, by= c(key1="key2"))
# quote first# df1 %>% left_join(df2, by = c("key1" = key2))## Error in common_by(by, x, y) : object 'key2' not found# quote none# df1 %>% left_join(df2, by = c(key1 = key2))## Error in common_by(by, x, y) : object 'key2' not found
The text was updated successfully, but these errors were encountered:
This is just how R's parser works. c(a=b) is a call to the c function, with an argument named a whose value is the contents of the object b. If b doesn't exist, it will throw an error. c("a"="b") still has an argument named a (because strings are magically promoted to names when on the LHS of an equal in a function call), but now its value is the string "b".
I believe @Hong-Revo has it right. If you look at Controlling how tables are matched from the dplyr docs or Defining the key columns in R4DS, you'll see that the by argument (when not NULL/a natural join) is a character vector or a named character vector.
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/
lockbot
locked and limited conversation to collaborators
Aug 27, 2018
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Inconsistency with left_join()'s by= argument, variable quotes are inconsistently parsed when matching different variables between first and second tibble. Quotes on first key don't matter, but the second key must be quoted.
The text was updated successfully, but these errors were encountered: