b-cubed-eu / b3gbi

B-Cubed General Biodiversity Indicators
https://b-cubed-eu.github.io/b3gbi/
Other
0 stars 1 forks source link

Check globally imported functions #20

Open damianooldoni opened 1 week ago

damianooldoni commented 1 week ago

Hi 👋 Just a note about some globally imported functions.

I think you can remove (most of the) @importFrom lines (L5-L10) in b3gbi-package.R.

Via Ctrl+F (Mac: @ + F) you can easily detect where a function is used throughout the package. It seems that:

Instead, I think you should add #' @importFrom dplyr %>% .data in order to use pipe %>% and .data. By importing %>% you can delete utils-pipe.R. By adding .data you can use it everywhere in filter(), mutate() or group_by(). Example: dplyr::filter(.data$column). Why? It will solve a lot of notes about "global variable x not found"` while running R CMD CHECK.

Please, let me know via this issue if I can help or get in contact with the B-Cubed devs community (see our #wp3-software-helpdesk Slack channel).

damianooldoni commented 1 week ago

A little code snippet to identify where adding .data or using "col_name" in tidyselect related functions (e.g. dplyr::select("col_name") instead of dplyr::select(col_name)):

package_name <- "b3gbi"
exported_functions <- getNamespaceExports(package_name)

globals <- purrr::map(exported_functions, ~ codetools::findGlobals(get(.x)))
globals

Ideally, this should only return base R functions and operators.