How to add external data file into developing R package?

喜欢而已 提交于 2019-12-05 14:20:29

You should manually create inst/extdata/file.csv in the base directory for your project (where DESCRIPTION is). You can put all the files you want to access in that directory.

Then to get the files in function examples or your vignette:

files <- lapply(list.files(system.file('extdata', package = 'my_package'), full.names = TRUE), read.csv)

system.file() returns the path to the extdata folder, then list.files() will create a vector of all the files in extdata. Finally, running lapply() with read.csv() should read the contents of all the files into a single list for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!