Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I document data sets with roxygen?

Is it possible to include .R files in the data directory of my package in the roxygen process?

I have put several .R files in the data directory. When they are sourced with data(), they read in raw data files and perform some transformations.

like image 611
Karsten W. Avatar asked Feb 22 '10 11:02

Karsten W.


People also ask

How do I create an R package document?

Creating Rd FilesUse the File -> New -> R Documentation command in RStudio. This command will allow you to specify the name of an existing function or dataset to use as the basis for the Rd file or alternatively will create a new empty Rd file.


2 Answers

Roxygen can be used anywhere within an R file (in other words, it doesn't have to be followed by a function). It can also be used to document any docType in the R documentation.

So you can just document your data in a separate block (something like this):

#' This is data to be included in my package #' #' @name data-name #' @docType data #' @author My Name \email{blahblah@@roxygen.org} #' @references \url{data_blah.com} #' @keywords data NULL 
like image 79
Shane Avatar answered Sep 19 '22 21:09

Shane


As of roxygen2 >4.0.0, you can document the data object defined elsewhere by documenting the name of the object defined as a string:

#' This is data to be included in my package #' #' @author My Name \email{blahblah@@roxygen.org} #' @references \url{data_blah.com} "data-name" 
like image 34
hadley Avatar answered Sep 21 '22 21:09

hadley