In this article, we talk about R Programming Language. We discuss its uses, the niche group of people who greatly benefit by this, its advantages above some of the other programming language for its specific purpose and later dive deeper into its Data types and get hands on experience with programming.

To Read the Previous Article — An Approach to Data Analytics Using Python.

R Programming Language(R): R is a programming language which is widely used for graphics and statistical computing. R Foundation for Statistical Computing supports the R language and has also provided free software environment. Statisticians and data miners widely use the R programming language which enables them to develop statistical software and data analysis. It is an amazing program to perform statistics operation and since it is open source, it is strongly supported by the R Community too.

Why R?

We took a dive into Python with “An Approach to Data Analytics Using Python.” There are many reasons to choose R Programming over Python for multiple scenarios for different reasons. First of all, if you employ a lot of Statistics, R is elegant for this. Most seasoned statisticians have a penchant for R over Python in day-to-day work. Many who have experienced both Python and R programming language agree on that first learning steps are way easy in R. And R has exceptional visualizations tools. Visualization is better with R packages than on Python.

Today, we’ll learn to run R, open files and do some simple data-wrangling. We’ll experiment with input file formats and do some calculations with R. After that, we’ll dive into Data Frames.

Get Started:

First of all, please download RStudio from the following link: It is freely available via: https://www.rstudio.com/.

After that install R into your system using this link.

RStudio

It is a really nice Integrated Development Environment for R. It enables statisticians and researchers to develop statistical programs,

In this article, we’ll demonstrate how to use RStudio, load in a file and run code.

Data Syntax

It can be defined as the way statements can be structured in a language. We can understand it by thinking of grammar in our real-world linguistic languages. Some of the syntaxes for working with R-objects are as follows:

Variables

Atomic Variables: x <- 5

Vectors: v <- c(2,4,6,8)

Data frames: df <- matrix(c(1,2,4,9,”a”,”r”), nrow = 2)

Data Structures

Data Structures can be defined as some particular method of organizing data such that it can be used effectually. Data can be stored in a variety of ways such as follows:

  • Array
  • Linked List
  • Stack
  • Queue
  • Binary Tree
  • Binary Search Tree
  • Heap
  • Graph
  • Matrix

Data types

In contrast to other programming languages like Java and C, the variables in R is not declared as some particular data type. The variables in R language are assigned with R — objects and that data type of the R-objects becomes variable’s data type. Data can be structured as numeric, characters and factors.

Some of the commonly used R-objects are as follows,

Vectors

They are known as the most basic R data objects which are mainly of six different types. Known as Atomic Vectors, they are integer, complex, logical, double, raw and character.

Using colon operator with numeric data,

  1. # Creating a sequence from 6.6 to 12.6.
  2. v <-6.6:12.6print(v)

The sequence is created with the values of v as follows,

Lists

List in R is created using the functions list(). It can contain different types of elements such as vectors, numbers, strings and another list.

Creating a List

  1. # Create a list containing numbers, strings, vectors and a logical values.
  2. list_data <- list(“Yellow”, “Brown”, c(1,2,3), FALSE, 35.53, 999)
  3. print(list_data)

Matrices

Matrices in R consists of element which are of the same atomic types and are arranged in two-dimensional rectangular format.

Creating Matrices

  1. # Create two 2x3 matrices.
  2. matrix1 <- matrix(c(1, 2, -1, 2, 8, 9), nrow = 2)
  3. print(matrix1)
  4. matrix2 <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2)
  5. print(matrix2)
  6. # Add the matrices.
  7. result <- matrix1 + matrix2
  8. cat(“Result of addition”,”\n”)
  9. print(result)

To Read the Full Article, Check it out at: https://bit.ly/34gXT2c

Man on a Mission - to create epochal impact

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store