Tuesday, September 6, 2011

Read in a .R script file

Sometimes you will need to run several different commands in order to reach you desired output. If you are running the same set of code over and over again, changing only a single parameter, then this can be type-heavy. So why not just make a script file? Once you've done so, all you will need to do, is make the single change, and then read in the script file and let R do the rest.

To read in your awesome script file just use source():

> source('/path/to/.R')

As you can see, you will most likely not need any further options. But if you want to see those options that are available, just run help(source) to bring up the documentation.

Ciao!

No comments:

Post a Comment