I'm creating an R package and I need it to include a couple of non R script files which get called by one of my functions. I need these script files to be distributed with the package, naturally. So that leaves me with two questions:
I've tried to find the answer in the Writing R Extensions document, but it didn't jump out at me. And, of course, I didn't read the whole thing. Am I being too honest here?
An R file is a script written in the R programming language. These files end with an . R extension.
Click on the Open an existing file icon in the RStudio toolbar. A Choose file dialog will open. Select the R script you want to open [this is one place where the . R file extension comes in handy] and click the Open button.
The R and RStudio programs are typically used to open R files since they provide helpful IDE tools. You can also use a plain text editor to view the contents of an R script.
There are two ways to create an R file in R studio: You can click on the File tab, from there when you click it will give a drop-down menu, where you can select the new file and then R script, so that, you will get a new file open.
I think you want either exec/
at the top-level (even though that is labeled 'still experimental, or subdirectory of inst
as everything in inst/
gets copied verbatim into the package.
A quick example from the packages I have expanded in source is gdata which has inst/perl
, inst/xls
and inst/bin
. These you could then call from R itself by computing the path of the installed package using system.file()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With