Introduction and Installation of R


R is:
  • A programing language developed at AT&T Bell Laboratories by Robert Gentleman and Ross Ihaka
  • An alternative to S language
  • A free, open source language, with highly active community members
  • Available across all platforms (Linux, Mac, Windows)
  • The RStudio program can run on a desktop or through a web browser.
Due to its underlying philosophy and design; R is useful for statistical computation and graphic visualization. R has a worldwide repository system—Comprehensive R Archive Network (CRAN). It can be accessed at http://cran.r-project.org. As of 2011, there were more than 3,000 such packages hosted on CRAN and many more on other websites.

You can install R from the following two sources:
CRAN Website: http://cran.r-project.org/
RStudio: https://www.rstudio.com/products/rstudio/download/

R Installation: 
First, you will learn how to install R on Windows from the CRAN website. You can download the package from: https://cran.r-project.org/bin/windows/base/.
  1. Download R 3.X.X for Windows executable file (.exe).
  2. Click “Next” in the Setup Wizard. (You may leave the setting as default.)
  3. Finally, open R console (RGUI from your desktop).
Now, you will learn how to install R on Windows from the RStudio website.
  1. Download RStudio from https://www.rstudio.com/products/rstudio/download/.
  2. Run the installation file.
  3. Open RStudio.
The different areas of RStudio are depicted below:
In RStudio, you can set the workspace by clicking Tools -> Global Options.
  • getwd() -return working directory
  • setwd() -set working directory
Many data scientist programmers and statisticians use R to design tools for analyzing data and to contribute their codes as pre-assembled collections of functions and objects called packages. You can install an R package by clicking GUI RStudio ->Tools -> Install Packages or directly from packages tab in File/Package Panel
Getting Started : Quick Tour!!

R has many operators to perform different mathematical and logical operations. These can be categorized as follows:
Arithmetic Operators: used for mathematical operations like addition and multiplication, look at the table below:
Operator
Description
+
Addition
-
Subtraction
*
Multiplication
/
Division
^
Exponent
%%
Modulus
%/%
Integer Division
Logical Operators: These operators are used to perform Boolean operations such as “AND” and “OR.”, look at the table below:
Operator
Description
!
Logical NOT
&
Element-wise logical AND
&&
Logical AND
|
Element-wise logical OR
||
Logical OR
Relational Operators: used to compare two values, look at the table below:
Operator
Description
< 
Less than
> 
Greater than
<=
Less than or equal to
>=
Greater than or equal to
==
Equal to
!=
Not equal to
Assignment Operator: These operators are used to assign values to variables. Variables are assigned using “<-”, although “=” also works.

Lets do a simply hello world program and execute as below.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.