Skip to content

Fix all no visible global function definition for NOTEs in R CMD CHECK #21

@arilamstein

Description

@arilamstein

We should aim to have all the functions in tbltools produce the same results on different machines, regardless of what packages they have installed or loaded.

Currently when you run R CMD CHECK you get a lot of NOTEs like this:

   extract_tree: no visible global function definition for ‘data_frame’

My understanding is that this message says "There is no global function for data_frame. So I will have to look". This is an issue because the same function can be defined by multiple packages. And if that is the case, I believe that R will simply choose the first one that it encounters. This means that the function can potentially give different results depending on which packages are loaded first.

This type of bug can be very hard to track down. Quite literally, the function might (harmlessly) be using a different version of the function that you intend right now. But in the next version of the package it could be modified, or removed (in which case the function uses a different package's version of the function).

I addresses some of these issues with my recent PR. But I will need to pair program with @dholstius in order to do the rest. (For example, some of the functions are multiply defined in data.table and dplyr. I've never used data.table myself, so I can't confidently say which version he intended to use in the code).

The solution to each of these NOTES is:

  1. decide which package's function you want to use
  2. Add the following roxygen2 annotation to the top of the function #' @importFrom <package> <function>

For reference, in the case of the data_frame example above, here is what I see when I type ??data_frame:
Screen Shot 2021-04-09 at 9 35 27 AM
It appears that data_frame is defined in at least 3 packages (tibble, vctrs and rcmdcheck). We should define which version we want R to use in exact_tree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    checkNecessary to pass R CMD CHECK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions