Introduction to R Programming
Synopsis:
This blog entry is the first post of R programming series. In this post, I will be introducing you to R Programming and some useful code snippets.
Introduction to R:
R is a software programming language for statistics and data science. There are wide variety of packages for data processing, visualization, analysis built for R.
Installation:
R can be downloaded by following instructions from CRAN
R Studio:
R studio is an IDE for writing and executing R programs. It can be downloaded here
[gallery ids=”50"]
Hello World !!
The R code and data location will be found at working directory.
Setting working directory:
setwd("/tmp/RCode/")
Get work directory location:
getwd()
Installing packages
install.packages("somepackage")
Loading library
library(somepackage)
To get more information about the library before loading it
library(help=somepackage)
Helloworld.R
print("Hello world")
Running the Helloworld.R is very simple.
> source("Helloworld.R")
[1] "Hello world"
>
SWIRL:
You can learn basic R programming with a “R Programming” course in Swirl.
I recommend you to take a look at it to get hands-on practice of R. Please run the following commands in R console to get started with Swirl R course.
> install.packages("swirl")
> library(swirl)
Here is a screenshot of how it looks in your terminal
[caption id=”attachment_52" align=”alignnone” width=”300"]
Swirl[/caption]
I like to summarize this post with one more handy command for clearing the console.
CTRL + L
Thanks for watching this post. I will show some useful code snippets used in R for data analysis in my following posts. Until then Good Bye!!
UPDATE: There is an online swirl browser and course from data camp to learn “R programming” online.