R is a powerful and versatile scripting language usually used for data analytics and visualizations. Due to its expressive syntax and easy-to-use interface, it has grown in popularity in recent years. R is a free and open source programming language. With its rapid development, evolving user community and whole host of packages available, it stands out as an important tool in a data scientist's toolbox.
This tutorial is aimed at people who want to start learning R from the beginner's level. We begin with the basics, discussing different programming constructs and structures of R, and move towards more advanced topics. We also give easy-to-follow examples to let you grasp the concepts introduced.
Reasons for using R
- Easy and powerful tool for data handling, modelling and storing
- Designed for working with data and its visualizations
- Object oriented programming features
- Large collection of already written packages (no need to start from scratch)
- Most importantly it's FREE!
How to get R
R is available on major operating system platforms like Windows, Linux and MacOS. It can be downloaded for free from the official website. Installing it on your machine is pretty straight forward from there.
The R command prompt
When you start R, the first thing you will see is the R console with the default "
>" prompt. We can start typing commands directly at the prompt and hit return to execute it. If the command is incomplete when you hit return, the prompt changes to "
+" and continues to take input until the command is syntactically complete. Alternatively, we can execute R commands stored in an external file using the function
source() as follows.
> source("example.R ")
To exit the command prompt we can call the
q() function (as in quit).
Getting help in R
To get help on specific topics, we can use the
help() function along with the topic we want to search. We can also use the
? operator for this.
We also have the
help.search() function to do a search engine type of search. We could use the
?? operator for this.