Hi I could find many resources on reading external file into a developing package like this https://r-pkgs.org/data.html . But is it even possible to read an external data folder into a package ? Instead of passing a file (or data frame), I would like to pass a folder like from GitHub or can someone recommend any other ways on how people approach this problem ?
Asked
Active
Viewed 36 times
0
-
Yes, it is possible, but you haven't really described your problem clearly enough here - what have you tried so far, and where did you get stuck? What's wrong with just having the folder as a subdirectory of `inst` in your package's source files? – Allan Cameron Feb 08 '22 at 07:24
-
Relevant doc: https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Data-in-packages – Mikael Jagan Feb 08 '22 at 08:22
-
"External" data in this context doesn't refer to data from anywhere; it refers to data from somewhere in your package other than the `data` directory, usually `inst/extdata`. – Mikael Jagan Feb 08 '22 at 08:24
-
From [here](https://r-pkgs.org/intro.html), "In R, the fundamental unit of shareable code is the package. A package bundles together code, data, documentation, and tests...". Thus, without further explanation, the concept of "reading external file into a developing package" seems to be an oxymoron. – Limey Feb 08 '22 at 09:10
-
Thanks. @MikaelJagan These files are consumed within a function in my package. So a function within my package is calling is calling an external package that use these files. – Xion Feb 09 '22 at 04:07
-
1Then include that package as a dependency of your package in `DESCRIPTION`, and use `system.file` to obtain relevant paths from inside your function. – Mikael Jagan Feb 09 '22 at 04:24