roxygen2

What does “Error in namespaceExport(ns, exports) : undefined exports” mean?

半腔热情 提交于 2019-11-30 17:08:50
When building a package, I got the error Error in namespaceExport(ns, exports) : undefined exports: FooBarBaz What does this mean, and how do I fix it? This error occurs when you try to export an object that doesn't exist. That is, the package NAMESPACE file contains the line export(FooBarBaz) but FooBarBaz doesn't exist in the package. One case where this error can occur is when you are trying to create a common help page for several functions using roxygen2 . In the example below, f and g are related functions to be documented in the WidgetUtils page. #' Widget-related functions #' #'

What does “Error in namespaceExport(ns, exports) : undefined exports” mean?

假装没事ソ 提交于 2019-11-30 16:27:50
问题 When building a package, I got the error Error in namespaceExport(ns, exports) : undefined exports: FooBarBaz What does this mean, and how do I fix it? 回答1: This error occurs when you try to export an object that doesn't exist. That is, the package NAMESPACE file contains the line export(FooBarBaz) but FooBarBaz doesn't exist in the package. One case where this error can occur is when you are trying to create a common help page for several functions using roxygen2 . In the example below, f

Error when building R package using roxygen2

☆樱花仙子☆ 提交于 2019-11-30 13:52:34
I have 2 files, Rfile.R and Cppfile.cpp. Contents in Cppfile.cpp: #include <Rcpp.h> using namespace Rcpp; // [[Rcpp::export]] int CPPF(int k){return ++k;} Contents in Rfile.R: RF<-function(k){return(CPPF(k))} I want to build an R package based on the 2 files. I use the lastest versions of Rstudio and Roxygen2. I tried 3 ways to build the package with or without Roxygen2, and had different results: New Project->New Directory->R package->Type:Package w/Rcpp, add both Rfile.R and Cppfile.cpp as source files. Build & reload, everything works out fine. The functions work as they do. New Project-

Include data examples in developing R packages

耗尽温柔 提交于 2019-11-30 12:46:10
问题 I am eager to learn how to incorporate data examples as comments written above the functions, such as: ##' @examples ##' ## Set working directory... ##' ## Load data into R session: ##' data <- system.file("extdata", "data.txt", package="...", sep="\t", header=TRUE, stringsAsFactors = FALSE) ##' ##' ## For reproducible results: ##' set.seed(999) I put my "data.txt" file in the directory: /pkg_Name/inst/extdata/. However, R CMD check indicates error in this step. If I proceed to R CMD build

How to extend S3 method from another package without loading the package

。_饼干妹妹 提交于 2019-11-30 11:35:12
I am developing a package which has the function forecast.myclass . I want that function to work nicely with forecast package. I.e. when forecast package is loaded the code forecast(object) should call forecast.myclass from my package. Since I need only generic definition of forecast from the package forecast , and I do not use any other function from the package forecast I am reluctant to include it in the Depends. So I define the generic in my package in the following way: ##' ##' @export forecast <- function(object,...) UseMethod("forecast") ##' @rdname forecast.midas_r ##' @method forecast

Rd file name conflict when extending a S4 method of some other package

杀马特。学长 韩版系。学妹 提交于 2019-11-30 10:40:51
Actual question How do I avoid Rd file name conflicts when a S4 generic and its method(s) are not necessarily all defined in the same package (package containing (some of) the custom method(s) depends on the package containing the generic) and using roxygenize() from package roxygen2 to generate the actual Rd files? I'm not sure if this is a roxygen2 problem or a common problem when the generic and its method(s) are scattered across packages (which IMHO in general definitely is a realistic use-case scenario if you follow a modular programming style). What's the recommended way to handle these

Can RStudio automatically generate an roxygen template for a function?

五迷三道 提交于 2019-11-30 05:37:45
Does RStudio support any automated roxygen template creation? In Emacs-ESS, C-x C-o will produce an roxygen template for a function. For example, it will automagically convert this: foo <- function(x,y) x+y into this: ##' .. content for \description{} (no empty lines) .. ##' ##' .. content for \details{} .. ##' @title ##' @param x ##' @param y ##' @return ##' @author David foo <- function(x,y) x+y Does similar functionality exist within RStudio? updates as of ESS 12.09-2 , the command has been changed to C-c C-o C-o this feature has been implemented in Rstudio: CTRL+ALT+SHIFT+R (Converting

Documenting setter functions with roxygen

那年仲夏 提交于 2019-11-30 04:45:22
问题 I have a function that does nothing more than ads a unique attr to any R object. Base demo: #' Setter function #' @param x an R object #' @param value a character value to set #' @export `foo<-` <- function(x, value){ attr(x, 'foo') <- value return(x) } This works like a charm except for generating a good Rd file, relevant part: \usage{ foo(var, value) <- value } And of course it triggers a warning while running R CMD check as it should be foo(var) <- value . Any hints would be really

devtools roxygen package creation and rd documentation

筅森魡賤 提交于 2019-11-30 04:02:18
I am new to roxygen and am struggling to see how to be able to use it to quickly create a new/custom package. I.e. I would like to know the minimum requirements are to make a package called package1 using devtools , roxygen2/3 so that I can run the commands require(package1) fun1(20) fun2(20) to generate 2000 and 4000 random normals respectively So lets take the simplest example. If I have two functions fun1 and fun2 fun1 <- function(x){ rnorm(100*x) } and fun2 <- function(y){ rnorm(200*y) } the params are numeric, the return values are numeric. I'm pretty sure this isn't an S3 method, lets

Include data examples in developing R packages

一曲冷凌霜 提交于 2019-11-30 03:03:07
I am eager to learn how to incorporate data examples as comments written above the functions, such as: ##' @examples ##' ## Set working directory... ##' ## Load data into R session: ##' data <- system.file("extdata", "data.txt", package="...", sep="\t", header=TRUE, stringsAsFactors = FALSE) ##' ##' ## For reproducible results: ##' set.seed(999) I put my "data.txt" file in the directory: /pkg_Name/inst/extdata/. However, R CMD check indicates error in this step. If I proceed to R CMD build and R CMD install, then after loading the package, I cannot get the data into R session... Could anyone