Hi there, welcome to week 2 session.
Today we will learn,
- Why did I chose R over python
- Introduction to R language
- Basics of R
Why R over python?
We can choose R or python for data analysis. If you are already familiar with python, you can go with python. But I was newbie in both technologies.
I selected R because of the following reasons.
- R is object-oriented
- R is a functional programming language
- Operator overloading is much easier in R than in Python
- Parallelism in R has been much further developed than in Python
- R is designed for statistical analysis
- R is great for exploratory work
- R has huge number of packages and readily usable tests that often provide you with the necessary tools to get up and running quickly
- R can even be part of a big data solution
Introduction to R language
R was created by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand, and is currently developed by the R Development Core Team, of which Chambers is a member.
As you know, we need an environment to run any program. You need to have r-base to run R programs.
You can download r-base by following below links.
For Windows machine, click here
For mac OSX machine, click here
For Linux machine, click here
(if any of the link is broken, get the r-base from cran website)
Now we have r-base. We can start coding! But we always prefer to work with IDEs than working on command line. Even R has a beautiful IDE called RStudio.
RStudio is an open source IDE. You can download it from their website. Here is the link.
Basics of R
Hope you have installed r-base and RStudio on your machine. Now launch RStudio or r-base interface.
After R is started, there is a console awaiting for input. At the prompt (>), you can enter numbers and perform calculations.
> 1 + 2
We assign values to variables with the assignment operator “=”. Just typing the variable by itself at the prompt will print out the value. We should note that another form of assignment operator “<-” is also in use. I prefer using “<-” operator, for no specific reason!
> x = 1
All text after the pound sign “#” within the same line is considered as a comment.
> 1 + 1 # this is a comment
R functions are invoked by its name, then followed by the parenthesis, and zero or more arguments. The following apply the function c to combine three numeric values into a vector.
> c(1, 2, 3)
 1 2 3
Sometimes we need additional functionality beyond those offered by the core R library. In order to install an extension package, you should invoke the install.packages function at the prompt and follow the instruction.
R provides extensive documentation. For example, entering ?c or help(c) at the prompt gives documentation of the function c in R.
If you are not sure about the name of the function you are looking for, you can perform a fuzzy search with the apropos function.
 “.rs.scanFiles” “canCoerce” “cancor” “scan” “volcano”
I will be writing about Sentiment analysis of twitter and WhatsApp data in the next post.
Thanks for visiting my blog. I always love to hear constructive feedback. Please give your feedback in the comment section below or write to me personally here.