roxygen2

RStudio: Building package with roxygen2. Not producing NAMESPACE file

空扰寡人 提交于 2019-12-01 22:22:02
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 required Which is odd because I have selected in my build configurations that roxygen2 should be making

Turning an R S3 ordinary function into a generic

耗尽温柔 提交于 2019-12-01 11:02:24
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 write extra documentation for the new function, an other .Rd file is created and competes with the

“Could not find function” in Roxygen examples during CMD check

浪尽此生 提交于 2019-12-01 04:51:23
I'm running a CMD check on a package in RStudio, part of which analyses the @examples in the inline Roxygen documentation. I'm getting this error: checking examples ... ERROR Running examples in ‘packagename-Ex.R’ failed The error most likely occurred in: > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: checkDate > ### Title: Ensure that a date string is a valid date > ### Aliases: checkDate > > ### ** Examples > > checkDate("2017-05-06") Error: could not find function "checkDate" Within my .R file, the documentation is defined as: #' Ensure that a date string is a valid

How do I indicate collate order in Roxygen2?

陌路散爱 提交于 2019-12-01 03:47:32
Using roxygen2 documentation with devtools document function automatically generates a Collate: field in the package DESCRIPTION, regardless of whether or not it is necessary to load the package library files in a particular order. I'm working on a package with a bunch of S4 methods and want to be sure the class definitions are loaded before any methods or other classes using them, which I understand I can do with the Collate list, but I'm not sure how to indicate this in the roxygen2 documentation format. The roxygen2 manual makes some reference to an @include tag but that looks like it might

How to add class-specific alias without generic alias using Roxygen2?

断了今生、忘了曾经 提交于 2019-12-01 02:45:32
A simple example is that I have created an extension to show , which is a S4 base method. I don't want to cause a disambiguation fork by re-documenting show in my package, and I also want to consolidate the documentation of my extension to show in the documentation for the new class, myPkgSpClass , by adding an alias for show,myPkgSpClass-method . #' @export #' @aliases show,myPkgSpClass-method #' @rdname myPkgSpClass-class setMethod("show", "myPkgSpClass", function(object){ show(NA) }) The problem I'm having, is that this results in an serious warning during documentation-build by roxygen2,

“Could not find function” in Roxygen examples during CMD check

早过忘川 提交于 2019-12-01 02:19:19
问题 I'm running a CMD check on a package in RStudio, part of which analyses the @examples in the inline Roxygen documentation. I'm getting this error: checking examples ... ERROR Running examples in ‘packagename-Ex.R’ failed The error most likely occurred in: > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: checkDate > ### Title: Ensure that a date string is a valid date > ### Aliases: checkDate > > ### ** Examples > > checkDate("2017-05-06") Error: could not find function

How do I indicate collate order in Roxygen2?

筅森魡賤 提交于 2019-12-01 00:41:23
问题 Using roxygen2 documentation with devtools document function automatically generates a Collate: field in the package DESCRIPTION, regardless of whether or not it is necessary to load the package library files in a particular order. I'm working on a package with a bunch of S4 methods and want to be sure the class definitions are loaded before any methods or other classes using them, which I understand I can do with the Collate list, but I'm not sure how to indicate this in the roxygen2

In Sublime Text 3, how can I change the comment character?

十年热恋 提交于 2019-11-30 23:06:53
I like the auto-comment feature Ctrl + / , but I'd like to be able the change the character it uses arbitrarily. I have read many similar questions like this one , but it's not exactly a generic solution. How can I make the comment character use something different? The specific use case is that I'm writing R code and using Roxygen2 for documentation. This uses #' as the comment character, instead of just # . So I I'd like to set sublime to use #' because as is, I can't use it for Roxygen2 comments. Questions regarding Sublime2, like this one , refer to '.tmPreferences' files, but I have not

How to add class-specific alias without generic alias using Roxygen2?

六月ゝ 毕业季﹏ 提交于 2019-11-30 22:32:30
问题 A simple example is that I have created an extension to show , which is a S4 base method. I don't want to cause a disambiguation fork by re-documenting show in my package, and I also want to consolidate the documentation of my extension to show in the documentation for the new class, myPkgSpClass , by adding an alias for show,myPkgSpClass-method . #' @export #' @aliases show,myPkgSpClass-method #' @rdname myPkgSpClass-class setMethod("show", "myPkgSpClass", function(object){ show(NA) }) The

Documenting setter functions with roxygen

随声附和 提交于 2019-11-30 20:52:54
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 apprecieted! Update : thanks to richierocks it seems there is a fix You can use the roxygen tag @usage Here is