# R packages: How to access csv files in data subfolder? [closed]

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?

• use paste0() to combine your base folder and all the csv's which you wish to read – coldy Oct 26 '19 at 18:41

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! – lars20070 Oct 27 '19 at 5:01