roxygen2 | Generate R package documentation from inline R comments
kandi X-RAY | roxygen2 Summary
kandi X-RAY | roxygen2 Summary
The premise of roxygen2 is simple: describe your functions in comments next to their definitions and roxygen2 will process your source code and comments to automatically generate .Rd files in man/, NAMESPACE, and, if needed, the Collate field in DESCRIPTION.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of roxygen2
roxygen2 Key Features
roxygen2 Examples and Code Snippets
Community Discussions
Trending Discussions on roxygen2
QUESTION
I receive the following note when trying to check my package: Found the following apparent S3 methods exported but not registered: is.nan.data.frame
.
Here is my document that I use with roxygen2
to create the package documentation:
ANSWER
Answered 2022-Mar-01 at 13:51I don't know Roxygen2
very well, but it appears that you have declared is.nan.data.frame
to be the is.nan
method for class data.frame
. Since you did that, you should call it as is.nan(df)
in the help page example.
If you don't want it to be the method, you just want it to be a regular function using dots in the name, then you shouldn't have @method is.nan data.frame
. But you indicate that you do want it to be a method.
Edited to add: Just to summarize your comments, the following fixes got rid of all the errors:
- use @export by itself without naming the function (as suggested by @KonradRudolph)
- remove the @usage line
- use
is.nan(df)
in the example (as I suggested)
QUESTION
ANSWER
Answered 2022-Feb-18 at 17:37Just to demonstrate that it's possible once you've integrated mathjaxr
correctly:
QUESTION
I want to write a vignette explaining my R package. Inside the vignette, I want to explain one input to a certain function.
Basically, what I would write in the vignette is the same as I wrote in the @param section of the roxygen comments to my function.
To avoid writing the same things twice, is there a way that I can insert the roxygen2 description of a function input into a vignette?
...ANSWER
Answered 2022-Jan-22 at 10:48The printr package of Yihui Xie provides what I need, see https://cran.r-project.org/web/packages/printr/vignettes/printr.html#help-pages.
QUESTION
I'm writing an R package using roxygen2
for documentation. I'm using the @includeRmd
tag to reduce duplication, and this works well to generate consistent documentation across the help files, vignette, and pkgdown
website.
My only issue is that, when I use the tag to insert examples, R CMD check
gives me a nasty warning. Here is my setup:
R/adder.R
... source code for function with roxygen2
block
ANSWER
Answered 2022-Jan-22 at 01:03Your usage of the @includeRmd
tag does not appear to be supported. You can use it to generate a Description or (sub)sections of Details, but not Examples. The documentation states:
It is currently not possible to document function arguments, return values, etc. in external Rmd documents.
That isn't too surprising, for a couple of reasons:
R CMD check
expects the\examples{}
block to contain verbatim R code, not Markdown, so injecting Markdown into the block without preprocessing is doomed to fail. Due to the chunk header and footer, the following is not valid R code:
QUESTION
I want to cite another package (the whole package, not just a function from it) in the documentation of some functions I'm developing. I am using Roxygen2 comments to document my package functions.
I cannot find a way to create a link to a whole third-party package using Roxygen2. To link to a package function, one would write [pkg::fun()]
but I don't know how to create a link to the package itself.
Some packages expose a general man page, and it's possible to link to it via e.g. [pkg::pkg]
.
But many packages don't have this and there's just a general package vignette with the list of functions and a link to the description:
Such page can be reached by clicking on a package name in the packages tab in RStudio.
How can I link to it from a function documentation made in Roxygen2 markdown.?
...ANSWER
Answered 2022-Jan-10 at 17:35You cannot link to the page that comes up when you click on the name of a package in RStudio's Packages pane. RStudio invisibly calls help(package = "")
, which renders the package's index.
From the R-exts
manual:
The markup
\link{foo}
(usually in the combination\code{\link{foo}}
) produces a hyperlink to the help for foo. Here foo is a topic, that is the argument of\alias
markup in anotherRd
file (possibly in another package).
Hence \link
and the equivalent Markdown markup supported by roxygen2
can only link to topics. A package index is not a topic in this sense because there is no corresponding Rd
file.
It might be best just to remind users that they can use help
to access the index of the package to which you are referring.
QUESTION
I am docummenting a dataset using roxygen2 (for my package development). I am trying to put cube meter (m^2) as a unit for one of my variable but it remains the same (m^2) when I am trying to see the documentation ?data. How can I generate units inside roxygen2?
Thank you
...ANSWER
Answered 2022-Jan-03 at 15:20You should use this line:
QUESTION
My colleagues and I routinely create ad hoc scripts in R, to perform ETL on proprietary data and generate automated reports for clients. I am attempting to standardize our approach, for the sake of consistency, modularity, and reusability.
In particular, I want to consolidate our most commonly used functions in a central directory, and to access them as if they were functions from a proprietary R package. However, I am quite raw as an R developer, and my teammates are even less experienced in R development. As such, the development of a formal package is unfeasible for the moment.
ApproachFortunately, the box
package, by Stack Overflow's very own Konrad Rudolph, provides (among other modularity) an accessible approach to approximate the behavior of an R package. Unlike the rigorous development process outlined by the RStudio team, box
requires only that one create a regular .R
file, in a meaningful location, with roxygen2
documentation (#'
) and explicit @export
s:
Writing modulesThe module
bio/seq
, which we have used in the previous section, is implemented in the filebio/seq.r
. The fileseq.r
is, by and large, a normal R source file, which happens to live in a directory namedbio
.In fact, there are only three things worth mentioning:
Documentation. Functions in the module file can be documented using ‘roxygen2’ syntax. It works the same as for packages. The ‘box’ package parses the
documentation and makes it available viabox::help
. Displaying module help requires that ‘roxygen2’ is installed.Export declarations. Similar to packages, modules explicitly need to declare which names they export; they do this using the annotation comment
#' @export
in front of the name. Again, this works similarly to ‘roxygen2’ (but does not require having that package installed).⋮
At the moment, I am tinkering around with a particular module, as "imported" into a script. While the "import" itself works seamlessly, I cannot seem to access the documentation for my functions.
CodeI am experimenting with box
on a Lenovo ThinkPad running Windows 10 Enterprise. I have created a script, aptly titled Script.R
, whose location serves as my working directory. My module exists in the relative subdirectory ./Resources/Modules
as the humble file time.R
, reproduced here:
ANSWER
Answered 2021-Jul-30 at 23:42QUESTION
I am refactoring an R package of another author (previous employee of my company). The author uses multiple variables in the roxygen2
examples that apparently are stored somewhere in the package. They are accessible with pkgname:::bar
. I renamed some of these variables across the entire package to improve naming consistency, let's say the variable is called foo
instead of bar
now, but the examples are not running any more upon devtools::check()
. The error: Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : object 'foo' not found
. However, I cannot find where they are defined. There are no objects in the data
folder that would be named bar
and searching for the variable name within all files (in RStudio and in Windows Explorer) does not reveal anything. Yet, pkgname:::bar
still works. Any ideas where I should look for bar
?
ANSWER
Answered 2021-Nov-30 at 18:08Variables can also be created in a normal R script of the package with foo <- new.env()
and then populated with content, e.g.
QUESTION
Im trying to set up a CI for a R package. In that regard I`m considering circleCI, which has worked out with previous R projects. However this time, I get the following error:
...ANSWER
Answered 2021-Nov-22 at 04:34The issue here is most likely that your run stage, here:
QUESTION
Is there a way to write roxygen2
tags for a function without devtools::document()
saving Rd files? I like the roxygen2-style for internal documentation (for other developers) of stuff that will never concern the end user. Right now, the "unnecessary" rd files end up shipping with the package.
Ideally, something like a @noRd
tag:
ANSWER
Answered 2021-Nov-19 at 12:15There literally is a @noRd
tag! I just didn't see it documented anywhere. Problem solved.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install roxygen2
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page