I have successfully written an R package and want to ship it with a specific csv
file. I placed the file in the data
and data-raw
subfolders.
read.csv("data/foobar.csv")
The above command fails. How can I read the csv
file?
I have successfully written an R package and want to ship it with a specific csv
file. I placed the file in the data
and data-raw
subfolders.
read.csv("data/foobar.csv")
The above command fails. How can I read the csv
file?
data-raw
is for storing data alongside a short R script that will do the conversion to R data for the user, and the user will just use the data()
function.[source] Alternatively, if you want the raw CSV to be user-accessible, I think you need to use the extdata
folder, as documented here. Then the user can get the actual path to the file on their system, after package installation, with system.file("extdata", ..., package = "mypackage")
. Then, finally, they can feed that path to read.csv()
with whatever options they like.
extdata
is what I was looking for. Thank you!
$\endgroup$
Oct 27, 2019 at 5:01