在开发 R 包中包含数据示例 [英] Include data examples in developing R packages

查看:14
本文介绍了在开发 R 包中包含数据示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想学习如何将数据示例合并为写在函数上方的注释,例如:

I am eager to learn how to incorporate data examples as comments written above the functions, such as:

##' @examples 
##' ## Set working directory...
##' ## Load data into R session:
##' data <- system.file("extdata", "data.txt", package="...", sep="	", header=TRUE, stringsAsFactors = FALSE)
##'
##' ## For reproducible results:
##' set.seed(999)

我将data.txt"文件放在目录:/pkg_Name/inst/extdata/中.但是,R CMD 检查在这一步中指示错误.如果我继续 R CMD 构建和 R CMD 安装,那么在加载包后,我无法将数据输入 R 会话......谁能告诉我出了什么问题?这是在函数帮助文档末尾包含数据示例的正确方法吗?

I put my "data.txt" file in the directory: /pkg_Name/inst/extdata/. However, R CMD check indicates error in this step. If I proceed to R CMD build and R CMD install, then after loading the package, I cannot get the data into R session... Could anyone tell me what went wrong? Is this the correct way to include data examples at the end of the function help document?

非常感谢!

推荐答案

请查看包含数据的 CRAN 包并复制他们的方法.几周前,我刚刚将数据添加到一个仅限工作的包中,它可以正常工作...

Please look at CRAN packages that include data and copy their approach. I just added data to a at-work-only package a few weeks back and it just works...

对于它的价值,手册有一个部分 1.1.5 包中的数据 解释它.

For what it is worth, the manual has a section 1.1.5 Data in packages which explains it.

这篇关于在开发 R 包中包含数据示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆