antoine-sac antoine-sac - 3 days ago 5
R Question

Are explicit roxygen import from base package needed?

Concrete example:

In my package, one of my functions uses

grep
form the
base
package.

Should I explicitly import
grep
or would that just introduce useless dependencies? I mean, everyone already has the
base
package, right?

For the sake of illustration:

#' Group_by with regex based column selection
#' Similar to `group_by` but grouping columns are selected with a regex.
#' @importFrom dplyr group_by
#' @importFrom base grep
#' @export
group_at <- function(df, pattern)
group_by_(df, .dots=grep(names(df), pattern=pattern, value=T))

Answer

From the Writing R Extensions manual sec.1.1.3:

It makes no sense to declare a dependence on R without a version specification, nor on the package base: this is an R package and package base is always available.

Comments