The question at hand is how to, within an R package, call and use a function with a dependency.
For example, I have written a function that uses the nFactors::parallel
function. This function makes a call to MASS::mvrnorm
, but when I run my function: function()
I get the following error: Error: could not find function "mvrnorm"
In my DESCRIPTION file I have (I am using roxygen2):
Imports:
MASS,
nFactors
and in my function.R
file I have tried including:
#' @import MASS
#' @import nFactors
as well as:
#' @importFrom MASS mvrnorm
#' @importFrom nFactors parallel
to no avail.
If I call library(MASS)
in the first line of my function, the problem is alleviated, but this loads the entire MASS
package for the user which isn't desired.
Thank you for any insight.
EDIT: This isn't simply a question of 'how can I utilize a particular function without importing the entire namespace'. This is more of a question of nested imports.