I wrote my first R program using R Studio, and quickly found out how this is different from running a java or C# program.
The R program is very simple.
The program generates 100 random numbers from normal distribution. So, using the interactive console, I typed “first()”, and I received my first error.
After some Google search, I learnt that I should “Source the script.” What does that mean? Well, R does not understand the “first()” command. You need to use the source() function to read the file (in this case first.R), and execute the commands in the sequence given in the file. RStudio actually saves the file script in a temporary file, and then uses the source() function to load the script into the current session.
After issuing the source() function on the file, and running the first() function, it works.
This is so much fun.