roxygen2

How to export S3 method so it is available in namespace?

落花浮王杯 提交于 2019-12-22 03:40:51
问题 I am creating a package and for S3 methods I export them using ##' @method predict myclass ##' @export predict.myclass <- function(object,...) { } Now when I load the package, then predict works on object of the class myclass , but function predict.myclass is not exported. In the NAMESPACE I only get the entry S3method(predict,myclass) . So is there a way to export predict.myclass too, so that user will get the code of predict.myclass when he(she) writes predict.myclass in the console? 回答1:

Documenting R6 classes and methods within R package in RStudio

北城以北 提交于 2019-12-22 02:03:15
问题 I am struggling with the documentation of an R6 class and its methods. My goal is to get the autocompletion in RStudio for the methods. At the moment, I only get the name of the method but no the help information I normally get using roxygen2 documenting a function with parameters etc. At the moment, this is my class: #' @importFrom R6 R6Class MQParameters <- R6::R6Class( 'MQParameters', public=list( initialize=function(file_path=NA) { private$location <- file_path mq_parameters <- read.delim

Exporting data in Roxygen2 so that they are available without requiring data()

我的梦境 提交于 2019-12-21 11:35:22
问题 After reading questions such as this SO question on documenting a data set with Roxygen I have managed to document a dataset (which I will refer to as cells ) and it now appears in the list generated by data(package="mypackage") and is loaded if I run the command data(cells) . After this, cells will appear when ls() is run. However, in many packages the data is immediately available without requiring a data() call. Also, the data names do not appear when ls() is run. An example is the

Exporting data in Roxygen2 so that they are available without requiring data()

﹥>﹥吖頭↗ 提交于 2019-12-21 11:35:11
问题 After reading questions such as this SO question on documenting a data set with Roxygen I have managed to document a dataset (which I will refer to as cells ) and it now appears in the list generated by data(package="mypackage") and is loaded if I run the command data(cells) . After this, cells will appear when ls() is run. However, in many packages the data is immediately available without requiring a data() call. Also, the data names do not appear when ls() is run. An example is the

How to specify in which order to load S4 methods when using roxygen2

荒凉一梦 提交于 2019-12-21 09:13:07
问题 I ran into following problem already multiple times. Say you have two classes, classA and classB described in the following files classA.R : #' the class classA #' #' This is a class A blabla #' \section{Slots}{\describe{\item{\code{A}}{a Character}}} #' @ name classA #' @rdname classA #' @exportClass classA setClass("classA",representation(A="character")) And classB.R #' the class classB #' #' This is a class B blabla #' \section{Slots}{\describe{\item{\code{B}}{an object of class A}}} #' @

Documenting function closures

柔情痞子 提交于 2019-12-21 04:11:13
问题 Suppose I have a function closure in my package, for example f = function(x) { x = x g = function(y) x <<- y h = function() x list(g = g, h = h) } l = f(5) l$g(10) l$h() What is the correct (in the official CRAN sense) way of documenting this function? In particular, I would like to use roxygen2 I would like to provide documentation for the functions g and h 回答1: One way would be to do something similar to ?family where you document g() and h() in the Value section of the .Rd file. Then

documenting dataset with roxygen2

穿精又带淫゛_ 提交于 2019-12-21 03:19:26
问题 I'm trying to document some datasets in an R package using roxygen2. Considering just one of these: I have mypkg/data/CpG.human.GRCh37.RDa which contains an object called CpG.human.GRCh37 and a file called: mypkg/R/cpg-data.R , which contains: #' @name CpG.human.GRCh37 #' @title CpG islands - human - genome build: GRCh37/hg19 #' @description This data set list the genomic locations of human CpG islands, #' with coordinates based on the GRCh37 / hg19 genome build. #' @docType data #' @usage

How do you write your package documentation? [closed]

余生长醉 提交于 2019-12-20 08:58:00
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I haven't quite figured out a sensible workflow for building packages and writing their documentation. I want as much of the process (and the documentation) as possible to be automatically generated. The obvious way to do this seems to be to use package.skeleton to create the basic package files, then

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

吃可爱长大的小学妹 提交于 2019-12-19 03:59:07
问题 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

Can RStudio automatically generate an roxygen template for a function?

本小妞迷上赌 提交于 2019-12-18 12:05:48
问题 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