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))
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.
By deleting the following terms associated to the package base
from NAMESPACE
import(base) ,
importFrom(base,system.file)
and in the DESCRIPTION file, delete the following term.
Imports: base
Then the following error vanished:
preparing package for lazy loading
Error in asNamespace(ns, base.OK = FALSE) :
operation not allowed on base namespace
ERROR: lazy loading failed for package 'aa'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With