Writing our first script

An R script is a simple text file containing a set of instructions. As long as these instructions are written in the “R Programming Language” then the computer will be able to understand them and perform the tasks we’ve asked.

To create our script, go to the text editor pane in RStudio and type into it:

print("Hello from R")

then go to File → Save and choose the save the file as “hello.R”.

We’ve just saved our R script with the name “hello.R”. We could have used any name we wanted. We chose “hello.R” as this is descriptive. The use of “.R” at the end is a sign to other people that this text file contains commands written in the R programming language.