简体   繁体   中英

How do I clear Error: object <some function> is not exported by 'namespace:<some package>' which shows up when building my R package?

I am using R Studio to author an R package. I've set up my R Studio preferences to create Roxygen documentation every time I click on "Build & Reload." I created an exported function of the form:

#' @title Dummy function
#'
#' @importFrom stats kurtosis
#' @importFrom magrittr %<>%
#' @importFrom dplyr mutate
#' @param input.df Input data frame
#'
#' @export

dummy.function <- function(input.df)
{
  output.df %<>% mutate(col2 = kurtosis(col1))
  return(output.df)
}

Shortly after hitting "Build & Reload" I realized that kurtosis is contained in the e1071 package, not the stats package. However, after fixing this in my Roxygen comments, I get the following error whenever I do Build & Reload:

Error: object "kurtosis" is not exported by 'namespace:stats'

It would appear that I've broken my package? How do I repair it?

It turns out that a pitfall of the "Build & Reload" workflow with Roxygen comments being written out on the fly is that the NAMESPACE file is written prior to building the package, but is not repaired or adjusted when making changes to the Roxygen comments. It turns out that in the above example, the NAMESPACE file had the following line:

importFrom(stats,kurtosis)

This line persisted even after I changed my importFrom Roxygen comment to get kurtosis from e1071 instead of stats. Deleting the offending line from the NAMESPACE file will fix the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM