数据集文档是否应该与 R 包中 use_data_raw 中的文件同名?
Should the data set documentation have same name the file in use_data_raw in R pakcages?
数据集的文档应作为 .R 文件包含在 R 目录中。 data-raw
目录还包括 .R 文件。他们的名字应该完全一样吗?
R 文件不需要同名。我的文档 R 文件(保存在 R
文件夹中)始终称为 data.R
。在 data.R 文件中,您可以记录 1 个或多个数据集。在下面的代码中,记录了一个名为 trial
的数据框
#' Results from a simulated trial of Placebo vs Drug
#'
#' A dataset containing the baseline characteristics of 200 patients
#' randomized to Placebo or Drug. Dataset also contains the trial outcome:
#' tumor response to the treatment.
#'
#' @format A data frame with 200 rows--one row per patient
#' \describe{
#' \item{trt}{Treatment Randomization}
#' \item{age}{Age, yrs}
#' \item{marker}{Marker Level, ng/mL}
#' \item{stage}{T Stage}
#' \item{grade}{Grade}
#' \item{response}{Tumor Response}
#' \item{death}{Patient Died}
#' \item{ttdeath}{Months to Death/Censor}
#' }
"trial"
但是,trial
数据集应由保存在 data
文件夹中的 trial.rda
文件共享。
数据集的文档应作为 .R 文件包含在 R 目录中。 data-raw
目录还包括 .R 文件。他们的名字应该完全一样吗?
R 文件不需要同名。我的文档 R 文件(保存在 R
文件夹中)始终称为 data.R
。在 data.R 文件中,您可以记录 1 个或多个数据集。在下面的代码中,记录了一个名为 trial
的数据框
#' Results from a simulated trial of Placebo vs Drug
#'
#' A dataset containing the baseline characteristics of 200 patients
#' randomized to Placebo or Drug. Dataset also contains the trial outcome:
#' tumor response to the treatment.
#'
#' @format A data frame with 200 rows--one row per patient
#' \describe{
#' \item{trt}{Treatment Randomization}
#' \item{age}{Age, yrs}
#' \item{marker}{Marker Level, ng/mL}
#' \item{stage}{T Stage}
#' \item{grade}{Grade}
#' \item{response}{Tumor Response}
#' \item{death}{Patient Died}
#' \item{ttdeath}{Months to Death/Censor}
#' }
"trial"
但是,trial
数据集应由保存在 data
文件夹中的 trial.rda
文件共享。