I have a dynamic automatic process where I pick up files, process them and left_join
them together.
I don't always get all the files so sometimes my RHS left_join
table is empty which consequently throws the error
Error: Not compatible with STRSXP: [type=NULL].
Consider following example
library(dplyr)
df <-structure(list(id = c(1, 2), var = c("a", "b")), class = "data.frame", row.names = c(NA,
-2L))
df2 <- structure(list(), class = "data.frame", row.names = integer(0))
df %>%
left_join(df2, by=('id'))
Is there a simple way to ignore/suppress the error for the join if the RHS table is empty?
Thanks