roxygen2

R package fails devtools::check, because “could not find function” even though the function is imported in NAMESPACE

╄→尐↘猪︶ㄣ 提交于 2020-07-21 05:25:11
问题 Trying to build my first R package using roxygen2 and devtools . I have added a function that uses %>% and mutate in the @examples section. When I run check() it fails, because it cannot find the function %>% or mutate . Based on this, this, and this I have tried the following: I have #' importFrom magrittr %>% and #' importFrom dplyr mutate in the function's .R file. I also have magrittr and dplyr under Imports: in the DESCRIPTION file. After running document() , my NAMESPACE file contains

Documenting generic S3 methods in R so that user can see documentation?

喜欢而已 提交于 2020-06-29 03:36:03
问题 I am extending the print() function by a method print.dmdSchemeSet() . This functions has additional arguments which I obviously have documented in the source files using roxygen2: #' Generic print function for \code{dmdSchemeSet} #' #' @param x object of type \code{dmdSchemeSet} #' @param ... additional arguments - not used here #' @param printAttr default \code{TRUE} - attributes are printed #' @param printExtAttr default \code{FALSE} - additional attributes are not printed (e.g. \code

Documenting generic S3 methods in R so that user can see documentation?

走远了吗. 提交于 2020-06-29 03:35:17
问题 I am extending the print() function by a method print.dmdSchemeSet() . This functions has additional arguments which I obviously have documented in the source files using roxygen2: #' Generic print function for \code{dmdSchemeSet} #' #' @param x object of type \code{dmdSchemeSet} #' @param ... additional arguments - not used here #' @param printAttr default \code{TRUE} - attributes are printed #' @param printExtAttr default \code{FALSE} - additional attributes are not printed (e.g. \code

Data not exported from namespace in R

心不动则不痛 提交于 2020-06-24 11:37:05
问题 I've set up and been regularly updating my R package to GitHub following Hadley's extensive documentation about Devtools, Roxygen2 etc., on my laptop. Yesterday I decided to use my main PC instead and am now looking to push changes up to GitHub. I got the following error after entering document() : Error: 'Adult_Females' is not an exported object from 'namespace:gbm.auto' Adult_Females is the name of the first data file in /Data. According to this (scroll down to 'Data') "files that live in

'data' is not an exported object from 'namespace:my_package'

只谈情不闲聊 提交于 2020-03-18 11:27:12
问题 I'm writing a function that uses an external data as follow: First, it checks if the data is on the data / folder, if it is not, it creates the data / folder and then downloads the file from github; If the data is already on the data/ folder, it reads it, and perform the calculations. The question is, when I run: devtools::check() it returns: Error: 'data' is not an exported object from 'namespace:my_package' Should I manually put something on NAMESPACE ? An example: my_function <- function(x

RStudio: Building package with roxygen2. Not producing NAMESPACE file

和自甴很熟 提交于 2020-03-16 06:21:28
问题 This is my first time building an R package, and doing it with the help of devtools and roxygen2. After writing a simple func in the R directory and making a DESCRIPTION file with devtools, I try to build and reload for the first time but I get an error - ==> devtools::document(roclets=c('rd', 'collate', 'namespace')) First time using roxygen2 4.0. Upgrading automatically... Documentation completed ==> R CMD INSTALL --no-multiarch --with-keep.source TestPack ... ERROR: a 'NAMESPACE' file is

RStudio: Building package with roxygen2. Not producing NAMESPACE file

青春壹個敷衍的年華 提交于 2020-03-16 06:21:20
问题 This is my first time building an R package, and doing it with the help of devtools and roxygen2. After writing a simple func in the R directory and making a DESCRIPTION file with devtools, I try to build and reload for the first time but I get an error - ==> devtools::document(roclets=c('rd', 'collate', 'namespace')) First time using roxygen2 4.0. Upgrading automatically... Documentation completed ==> R CMD INSTALL --no-multiarch --with-keep.source TestPack ... ERROR: a 'NAMESPACE' file is

Cannot call roxygenize function from Rscript batch file

微笑、不失礼 提交于 2020-02-02 01:29:13
问题 I am writing a script that uses roxygen2 to automatically roxygenize my package. I'd like it to be executable so that it can be part of a larger script to prepare and install the package, but I cannot make it work with Rscript for some reason. Here is the code: #!/usr/bin/env Rscript library(roxygen2) roxygenize('.', copy=FALSE) This works correctly if I start an interactive R session or if I submit the code using R CMD BATCH. However, I get this output and error if I run the script directly

Cannot call roxygenize function from Rscript batch file

爷,独闯天下 提交于 2020-02-02 01:29:12
问题 I am writing a script that uses roxygen2 to automatically roxygenize my package. I'd like it to be executable so that it can be part of a larger script to prepare and install the package, but I cannot make it work with Rscript for some reason. Here is the code: #!/usr/bin/env Rscript library(roxygen2) roxygenize('.', copy=FALSE) This works correctly if I start an interactive R session or if I submit the code using R CMD BATCH. However, I get this output and error if I run the script directly

Turning an R S3 ordinary function into a generic

北城余情 提交于 2020-01-21 09:10:12
问题 FYI, looks like this question already has a LISP equivalent. Recently I wanted to create a dataframe extension to the R base function setdiff and thought a generic would be nice. The following works but is clunky: #' @export setdiff.default setdiff.default <- setdiff #' @export setdiff <- function(x, ...) { UseMethod("setdiff") } #' @export setdiff.data.frame <- function(A, B) { A[!duplicated(rbind(B, A))[nrow(B) + 1:nrow(A)], ] } When you load the package, the base function is masked. If I