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

查看:297
本文介绍了在开发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="\t", 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...

对于它的价值,该手册有一个

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

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

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