Kar*_* W. 51 r documentation-generation roxygen r-package
是否可以在roxygen过程中将.R文件包含在我的包的数据目录中?
我在数据目录中放了几个.R文件.当它们使用data()获取时,它们会读入原始数据文件并执行一些转换.
Sha*_*ane 44
Roxygen可以在R文件中的任何地方使用(换句话说,它不必跟随函数).它还可以用于记录R文档中的任何docType.
所以你可以在一个单独的块中记录你的数据(类似这样):
#' 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
Run Code Online (Sandbox Code Playgroud)
had*_*ley 33
从roxygen2> 4.0.0开始,您可以通过记录定义为字符串的对象的名称来记录在别处定义的数据对象:
#' This is data to be included in my package
#'
#' @author My Name \email{blahblah@@roxygen.org}
#' @references \url{data_blah.com}
"data-name"
Run Code Online (Sandbox Code Playgroud)
Jer*_*lim 22
我发现研究ggplot2包中的例子很有用.
一些注意事项:
.r的R目录中的单个文件中.参见示例,diamonds数据集:
#' Prices of 50,000 round cut diamonds
#'
#' A dataset containing the prices and other attributes of almost 54,000
#' diamonds. The variables are as follows:
#'
#' \itemize{
#' \item price. price in US dollars (\$326--\$18,823)
#' \item carat. weight of the diamond (0.2--5.01)
#' \item cut. quality of the cut (Fair, Good, Very Good, Premium, Ideal)
#' \item colour. diamond colour, from J (worst) to D (best)
#' \item clarity. a measurement of how clear the diamond is (I1 (worst), SI1, SI2, VS1, VS2, VVS1, VVS2, IF (best))
#' \item x. length in mm (0--10.74)
#' \item y. width in mm (0--58.9)
#' \item z. depth in mm (0--31.8)
#' \item depth. total depth percentage = z / mean(x, y) = 2 * z / (x + y) (43--79)
#' \item table. width of top of diamond relative to widest point (43--95)
#' }
#'
#' @docType data
#' @keywords datasets
#' @name diamonds
#' @usage data(diamonds)
#' @format A data frame with 53940 rows and 10 variables
NULL
Run Code Online (Sandbox Code Playgroud)
这会生成一个如下所示的帮助文件:
