I'm building a package that uses tidyselect::where() in a function. However, when I reference tidyselect::where() I get the an error message Error: 'where' is not an exported object from 'namespace:tidyselect'. I can use the where function after running either library(tidyverse) or library(tidyselect), but I can't run it when using the :: syntax. I have tested this on both a windows 10 laptop and on MacOS Catalina with tidyselect 1.1.0 and tidyverse 1.3.0.
minimal example:
library(tidyverse)
iris <- as_tibble(iris)
iris %>% select(where(is.factor)) # works fine
iris %>% select(tidyselect::where(is.factor))
# Error: 'where' is not an exported object from 'namespace:tidyselect'
I can use tidyselect:: notation with other tidyselect functions. For example, this works fine.
to see non-exported functions you would use triple colons
tidyselect:::where
function (fn)
{
predicate <- as_function(fn)
function(x, ...) {
out <- predicate(x, ...)
if (!is_bool(out)) {
abort("`where()` must be used with functions that return `TRUE` or `FALSE`.")
}
out
}
}
<bytecode: 0x000001c6f5719188>
<environment: namespace:tidyselect>
but that its not exported means you shouldnt rely on it not to change/break in future versions.
Thank you. It certainly wasn't my intention to use a non-exported function. I read the documentation fairly carefully, and I didn't see any indication that where is a non-exported function. Is there something in its documentation that I am missing that indicates it is different from other selection helpers like all_of or ends_with?
Your comment also helped me find this github issue thread. It looks like the main reason where is not exported is "just hesitance regarding using up a good function name." https://github.com/r-lib/tidyselect/issues/201