Contents:
Creating and Running your first R Programme
What is R?
R is a programming language along with a free software specially developed for statistical computing and graphics.
It is licensed under a GNU project.
R is based on S programming Language which is combined with lexical scoping semantics which was created by John Chambers in 1976 at Bell Labs (formerly AT&T, now Lucent Technologies).
R has libraries to implement a wide variety of statistical and graphical techniques, including linear and nonlinear modelling, clustering, time-series analysis, classification, classical statistical tests etc.
R is an Interpreted language if the user passes input in the command line window the output will be generated by the computer.
The functionalities of R can be accessed from several scripting languages such as Python, Perl, Ruby F# and Julia.
R programming tool provides users with the following major functionalities in a single tool:
- Data Manipulation: R allows the users to shape present dataset into a format that can be easily accessed and analysed by slicing large multivariate datasets. In recent times R is one of the very few tools that provides users with great indexing techniques.
- Data Analysis: Any kind of statistical data analysis could be found in R. R is an open source development tool that is supported by a large community of statisticians and scientists. R has over 4000 packages that implements various statistical analysis tools that are related to model fitting, hypothesis testing, and machine learning along clustering techniques.
- Data Visualization: R contains many shelf graph functions which can be readily be used. R gives the developer capabilities to implement any visualization idea for any dataset. We can easily implement animated and interactive graphs in R.
Creating and Running your first R Programme
But before we get into creating a program let’s just first set up a proper environment for R programming.
To install R programming tool go to the following link and download the software and install it.
For Windows Users:
For Linux Users:
If you are on Linux platform then you can use this fast and easy command used in Linux which can be used to install R. The yum command is used for installing like this:
$ yum install R
For Ubuntu Linux or other Debian-related OSs, a more direct method is:
$ apt-get install r-base
Now Let’s Start using the RGui (64 -bit) which will be installed in the Installation folder which we had selected while installing the software.
We will write the following simple loop.
i = 0
repeat{if (i > 25) break else {print(i); i = i + 5;}}
This code will repeat the loop till the value is less than 25 and incremental value is 5
i <- 5
while (i <= 25) {print(i); i <- i + 5}
This code will repeat the loop till the value of I is less than or equal to 25 also the value of i has been set to 5 initially and is being incremented by 5.
for (i in seq(from=5, to=25, by=5)) print(i)
This is another way to iterate a value where from indicates initial value, to indicates end condition and by indicates incremental value.
The Output generated can be seen below
Syllabus of Data Science training in Mumbai