Files operation in R Language
Till now we have seen example by typing the code into command line and it works only for short scripts. So to execute R program later, we can store it in a text file (with extension .R). It can be run directly from the command line or from a running R instance.
Let’s see some of the stored R scripts.
In my system I have two R scripts bottle1.R and bottle2.R.
By using list.files() function we can display the stored R scripts in current working directory.
How to run a script in R
To run a script, pass a string with its name to the source function.
Press enter to run:
Now try to run bottle2.R
These are massage I have stored in both files.
We will learn more about files in upcoming tutorial.