gcamdata icon indicating copy to clipboard operation
gcamdata copied to clipboard

dplyr functions manually imported and written to NAMESPACE

Open pkyle opened this issue 7 years ago • 3 comments

Most of the R code chunks in gcamdata manually import functions from the dplyr library using the syntax:

importFrom dplyr [function]

As a result they are written to the NAMESPACE. However not all of the functions from dplyr that are used in gcamdata are manually imported in the code chunks. Because the entire package is already imported, to keep things tidy it would be ideal to remove all of the instances of individual function imports in the R code chunks.

pkyle avatar Jan 17 '19 02:01 pkyle

If I understand how this works correctly, including dplyr in the DESCRIPTION file does not actually import all of dplyr. We could call @Import dplyr, but this is generally frowned upon because of the possibility of namespace collisions (although maybe we don't care about that?)

Usually we have either the option of calling @ImportFrom dplyr mutate or just using dplyr::mutate() in the code. Generally we go with the first option throughout gcamdata, although there is definitely a combination of the two. However, I think that we only need to call @ImportFrom dplyr mutate once to always have mutate() available to all functions. We have a strange mix of sometimes calling @ImportFrom in the function documentation, sometimes not, and sometimes using dplyr::. We could simply move all of the imports to one file (as suggested here: https://roxygen2.r-lib.org/articles/namespace.html#importing-functions)

Does that sound right @pkyle @pralitp?

russellhz avatar Aug 04 '22 19:08 russellhz

☝️ That's all correct, @russellhz

bpbond avatar Aug 29 '22 08:08 bpbond

Thanks @bpbond! Probably makes sense to collect them in a central place then.

russellhz avatar Aug 29 '22 13:08 russellhz