Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using source subdirectories within R packages with roxygen2

Tags:

I would like to use a directory structure within the R folder for the source code of a package. For example, within my R folder I have an algos folder with functions I want to export and document. However roxygen2 by default does not seem to go through the subfolders of the R folder.

I tried to use the @include keyword as follows for a file at `R/algos/algo1.r'

#' @include algos/algo1.r 

but without success. Is there a simple way to use subfolder for the R source code?

like image 397
tlamadon Avatar asked Feb 15 '13 19:02

tlamadon


People also ask

How do I run roxygen2?

There are three main ways to run roxygen: roxygen2::roxygenise() . devtools::document() . Ctrl + Shift + D , if you're using RStudio.

How do I create a subfolder in R?

Suppose if you want to create a subfolder under the current directory you can choose the paste command and can set the working directory. If you are using RStudio then press Ctrl + Shift + H and choose the desired directory.

How do I write R package documents?

To add documentation to an R package, you need to create a subdirectory “ man ” containing a set of files, one per function, in a special R Documentation format ( . Rd ). These will be the source for the documentation for each function; R processes them to create plain text, PDF, and HTML versions.

How r package works?

R packages are a collection of R functions, complied code and sample data. They are stored under a directory called "library" in the R environment. By default, R installs a set of packages during installation. More packages are added later, when they are needed for some specific purpose.


1 Answers

Writing R Extensions has this to say (in Section 1.1.5) about subdirectories under the R directory:

The R and man subdirectories may contain OS-specific subdirectories named unix or windows.

Implied in this is that they can't have other subdirectories other than those two. This is confirmed in an r-devel thread and again later in another r-devel thread.

like image 179
Brian Diggs Avatar answered Sep 25 '22 09:09

Brian Diggs