Reputation: 872
I have multiple R scripts for different models and I need to make it easily accessible for other people to use. So I would like to have one script in which only contains sources to run the other scripts without people having to search through many files to find the right one. some of the scripts have more than one model in so if possible I would like to source only specific blocks of lines from those scripts.
For example to find the accuracy of ARIMA in different ways I have to run the following different scripts in turn;
The amount of different scripts causes the risk of an error to be higher. especially as within 3 of those scripts is 5 other models which if running myself I would just highlight the specific model I'm wanting to use and run, but for other people that may be more confusing.
I know that I have to use source()
to get the scripts to run but im stuck as to how to source only certain parts of the script and the correct way to source
Upvotes: 3
Views: 1418
Reputation: 48
You could make one code that automates the whole thing and then use knitr
to create a word, or pdf document of the whole thing for other people to read easily?
Upvotes: 1
Reputation: 3263
Rather than trying to source parts of scripts, move these bits of code into functions, and then just call the functions you need.
Start by searching around for how to write R functions
You can put all your functions into a single file, source it, and then make your recipes of functions with orders for others.
Upvotes: 3