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.
eg:
> 1 + 2
output:
[1] 3
[1] 3
Variable assignment
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!
eg:
> x = 1
> x
> x
output:
[1] 1
[1] 1
Comments
All text after the pound sign "#" within the same line is considered as a comment.
eg:
> 1 + 1 # this is a comment
output:
[1] 2
[1] 2
Functions
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.
eg:
> c(1, 2, 3)
output:
[1] 1 2 3
[1] 1 2 3
Extension Package
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.
eg:
> install.packages("package_name")
Getting Help
R provides extensive documentation. For example, entering ?c or help(c) at
the prompt gives documentation of the function c in R.
eg:
> help(c)
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.
eg:
> apropos("can")
output:
[1] ".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.
(I use R-Bloggers for updates on R, consider visiting this blog too!)
That is very interesting; you are a very skilled blogger. I have shared your website in my social networks! A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article.
ReplyDeleteR Programming Online Training
Really, these quotes are the holistic approach toward mindfulness. In fact, all of your posts are. Proudly saying I’m getting fruitfulness out of what you write and share. Thank you so much.. R Programming Training in Bangalore
ReplyDeleteR Programming Training Institute in Bangalore
Best R Programming Training in Bangalore
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleterprogramming training in bangalore
Really Good blog post.provided a helpful information.I hope that you will post more updates like this Data Science online Training India
ReplyDeleteThanks for sharing your innovative ideas to our vision. I have read your blog and I gathered some new information through your blog. Your blog is really very informative and unique. Keep posting like this. Awaiting for your further update.If you are looking for any Data science related information, please visit our website Data science training institute in bangalore
ReplyDeleteThanks for such a wonderful content. Our Motive is not just to create links but to get them indexed as will
ReplyDeleteIncrease Domain Authority (DA).We’re on a mission to increase DA PA of your domain
High Quality Backlink Building Service
Boost DA upto 15+ at cheapest
Boost DA upto 25+ at cheapest . Very Helpful