Occasionally, I need to join a data frame to (usually a modified) version of itself within a dplyr chain. Something like this:
df <- data.frame(
id = c(1,2,3)
, status = c('foo','bar','meh')
, spouseid = c(4,3,2)
)
df %>%
filter( status == 'foo' | status == 'bar') %>%
# join the filtered table to itself using the dot as the right-hand side
left_join(., by = c('id' = 'spouseid'))
When I try that, I get Error in is.data.frame(y) : argument "y" is missing, with no default
.