roxygen2

R with roxygen2: How to use a single function from another package?

我的梦境 提交于 2019-12-05 12:41:14
I'm creating an R package that will use a single function from plyr . According to this roxygen2 vignette : If you are using just a few functions from another package, the recommended option is to note the package name in the Imports: field of the DESCRIPTION file and call the function(s) explicitly using ::, e.g., pkg::fun(). That sounds good. I'm using plyr::ldply() - the full call with :: - so I list plyr in Imports: in my DESCRIPTION file. However, when I use devtools::check() I get this: * checking dependencies in R code ... NOTE All declared Imports should be used: ‘plyr’ All declared

Cannot call roxygenize function from Rscript batch file

家住魔仙堡 提交于 2019-12-05 05:31:27
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 as an executable via Rscript (and I get the error regardless of whether the script is in the current

What's the recommended package build workflow with packages that contain S4 classes? [duplicate]

纵饮孤独 提交于 2019-12-05 04:43:16
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to properly document S4 class slots using Roxygen2 I would like to build a package that contains S4 classes using R Studio and roxygen2 . I had already documented all my functions using roxygen2 syntax when I introduced a couple of S4 classes to my package. Now I realized that there's no '@slot' functionality out-of-the-box. So I wonder how can I keep all my documentation work for the other functions and

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

守給你的承諾、 提交于 2019-12-05 01:56:17
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? My answer is "don't do that". The user can methods(predict); getAnywhere('predict.myclass') or mypackage::

S3 method help (roxygen2)

北慕城南 提交于 2019-12-05 01:22:06
I am trying to use a S3 method in a package and thought I understood how to set it up after asking a question here: S3 method consistency warning when building R package with Roxygen But now I get results I don't expect. If I run the code below directly in R it gives me the expected results but if I compile it into a package I don't get the correct results (notice the word the gets counted twice when it should take only unique words from vector a ). I'm not sure what I'm setting up incorrectly. The .R file: #' Find Common Words Between Groups #' #' Find common words between grouping variables

Citing articles in R package using roxygen2 and BibTeX?

↘锁芯ラ 提交于 2019-12-05 00:04:30
I'm using roxygen2 as a tool for documenting my R package, and I found that there is a @references tag in roxygen2, but that seems to only accept free form text. I found some presentation about roxygen which has tags @bibliograph and @cite, but am I correct that there is no such thing in roxygen2? Should I then somehow take the references out of the bibtex-file and write them manually with appropriate formatting directly after the @references tag or is there some more clever way of doing this? I have about seven different articles I need to cite, over multiple functions/rd-files. Seems that

Documenting R6 classes and methods within R package in RStudio

懵懂的女人 提交于 2019-12-04 23:35:47
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(file_path, stringsAsFactors=FALSE) mq_parameters <- setNames(mq_parameters$Value, mq_parameters

Overwriting NAMESPACE and Rd with roxygen2

一个人想着一个人 提交于 2019-12-04 17:18:08
I create a new package with RStudio. In "Configure Build Tools", I check "Generate documentation with Roxygen". The first time I click on "Document" in the "Build" pane, everything works fine: ==> roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace')) First time using roxygen2. Upgrading automatically... Writing hello.Rd Writing NAMESPACE Documentation completed I get this NAMESPACE: # Generated by roxygen2: do not edit by hand export(hello) and this file hello.Rd : % Generated by roxygen2: do not edit by hand % Please edit documentation in R/hello.R \name{hello} \alias{hello}

why roxygen2 does not automatically update “Imports” in DESCRIPTION file?

亡梦爱人 提交于 2019-12-04 16:45:42
问题 I am trying to follow closely @hadley's book to learn best practices in writing R packages. And I was thrilled to read these lines about the philosophy of the book: anything that can be automated, should be automated. Do as little as possible by hand. Do as much as possible with functions. So when I was reading about dependencies and the (sort of) confusing differences between import directives in the NAMESPACE file and the "Imports:" field in the DESCRIPTION file, I was hoping that roxygen2

adding useDynLib through Roxygen [closed]

我与影子孤独终老i 提交于 2019-12-04 16:45:31
问题 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 6 years ago . I am converting my packages to use roxygen documentation, through the roxygen2 package. Now my package does not load and I think that is is because of the missing useDynLib(mypackage) call missing from the NAMESPACE file. How do I get this generated? 来源: https://stackoverflow.com/questions/8407615/adding