The setdiff()
function in dplyr is behaving differently when I execute it interactively vs in a .Rmd document with knitr. Specifically,
who_comp <- who %>% complete(country, year)
imp_miss <- dplyr::setdiff(union(who, who_comp), intersect(who, who_comp))
gives a dataframe/tibble interactively, but a list with knitr. Wrapping setdiff()
with as.tibble()
gives an error because the hypothetical tibble doesn't have any column names.
Why is it doing this, and is there a way to make it stop? It's the only function I've encountered that shows this difference.