如何指向R包中的目录?
我正在第一次尝试编写 R 包。我正在从硬盘加载一个 csv 文件,希望稍后将我的 R 代码和 csv 文件捆绑到一个包中。
我的问题是生成我的包时如何加载我的 csv 文件,我的意思是现在我的文件地址类似于 c:\R\mydirectory....\myfile.csv 但在我将其发送给其他人之后如何我有该文件的相对地址吗?
如果其他人不清楚,请随时纠正这个问题!
I am making my first attempts to write a R package. I am loading one csv file from hard drive and I am hoping to bundle up my R codes and my csv files into one package later.
My question is how can I load my csv file when my pakage is generated, I mean right now my file address is something like c:\R\mydirectory....\myfile.csv but after I sent it to someone else how can I have a relative address to that file?
Feel free to correct this question if it is not clear to others!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 csv 文件放入
data
目录或inst/extdata
中。请参阅编写 R 扩展手册 - 部分1.1.5 包中的数据。
要导入数据,您可以使用,例如,
或
You can put your csv files in the
data
directory or ininst/extdata
.See the Writing R Extensions manual - Section 1.1.5 Data in packages.
To import the data you can use, e.g.,
or
查看 R 帮助中的
package.sculpture
:这个函数package.sculpture
创建的目录结构包含一个data
目录。如果您将数据放在这里,它将随包一起分发。Look at the R help for
package.skeleton
: this functionThe directory structure created by
package.skeleton
includes adata
directory. If you put your data here it will be distributed with the package.