'where' is not an exported object from 'namespace:tidyselect'


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:

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.

iris %>% select(tidyselect::ends_with("Length"))

edit: can to can't :sleeping:, additional working example

to see non-exported functions you would use triple colons

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`.")
<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

I should add for anyone else that finds this thread that the recommended solution for using where in a package and passing the R CMD check is to use utils::globalVariables("where") for now. https://github.com/r-lib/tidyselect/issues/201#issuecomment-650547846

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.