gpt4 book ai didi

r - 如何记录数据集而不将其添加到“整理”字段?

转载 作者:行者123 更新时间:2023-12-02 05:59:39 31 4
gpt4 key购买 nike

我正在使用 roxygen2 来记录我正在开发的包的数据集。我知道你可以 use roxygen to document a dataset ,但是Shane's answer最终建议进行黑客攻击,虽然我宁愿避免。所以,我的问题是:

我应该将数据的 roxygen 文档放在哪里?

我目前有一个厌食症数据集的数据文档文件 (anorexia.sub.roxygen) in my /R folder

My Package Directory

因为据我所知,这是 roxygen2 唯一会寻找它的地方:

#' Family Treatment Weight change data for young female anorexia patients.
#'

#'
#' The MASS package includes the dataset \code{anorexia}, containing pre and
#' post treatment weights for young female anorexia patients. This is a subset
#' of those data, containing only those patients who received Family Treatment.
#'
#'
#' @name anorexia.sub
#' @docType data
#' @format A dataframe with 17 observations on the following 2 variables, no
#' NAs.
#'
#' \describe{
#'
#' \item{list("Prewt")}{Pretreatment weight of subject, in pounds.}
#'
#' \item{list("Postwt")}{Postreatment weight of subject, in pounds.}
#'
#' }
#' @references Venables, W. N. and Ripley, B. D. (2002) Modern Applied
#' Statistics with S. Fourth edition. Springer.
#' @source Hand, D. J., Daly, F., McConway, K., Lunn, D. and Ostrowski, E. eds
#' (1993) A Handbook of Small Data Sets. Chapman & Hall, Data set 285 (p.
#' 229)
#' @keywords datasets
NULL

roxygen2 生成文档就好了。但是,然后它将 anorexia.sub.roxygen.R 添加到 DESCRIPTION 中的 Collat​​e 字段:

Collate:
'granova.R'
'theme-defaults.R'
'granovagg.1w.R'
'granovagg.contr.R'
'granovagg.ds.R'
'help.R'
'anorexia.sub.roxygen.R'

我想我的问题是:我怎样才能拥有 roxygen2

  1. 自动从 roxygen block 生成数据文档,
  2. 不要将数据文档文件添加到 Collat​​e 调用中,并且
  3. 避免采用 requires a hack 的解决方案

最佳答案

因为在 package level 记录您的包裹是一个很好的做法以及function level ,我总是在 R 文件夹内有一个名为 packagename-package.R 的文件(例如,在您的情况下是 granovaGG-package.R ),其中我保留包文档以及数据文档。

因此您的 granovaGG-package.R 文件可能如下所示:

#' One sentence summary of your package.
#'
#' More detail
#' ...
#' @name granovaGG-package
#' @aliases granovaGG
#' @docType package
#' @title One sentence summary of your package.
#' @author \email{your.name@@email.com}
#' @keywords package
#' @seealso \code{\link{...}}
NULL
#' Your dataset documentation goes here.
#'
#' Exactly as in your example.
#' @docType data
#' etc.
#' ...
NULL

关于r - 如何记录数据集而不将其添加到“整理”字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7086805/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com