# R Programming Language

## A language for statistical analysis

·

We all know how crazy data science is nowadays. We hear a lot about data science projects and more job openings in that field. Data Science is considered the most significant part of a company as it can give future insights based on the data provided.

The R programming language plays a crucial role in processing a large amount of data and performing statistical analysis. There are many tools in data science which we will look at later in other blogs.

### So ... What is R?

R is both an environment and a language. It's an environment in the sense that it's an integrated suite of software packages and data that basically enable the R language. The R language in turn allows you to perform statistical analysis and data mining techniques such as the use of probability distributions, hypothesis testing, creating linear models, aggression, logistic regression, non-linear models and so on.

R is very versatile and it covers a whole range of statistical techniques and algorithms when it comes to data mining as well as analysis. Also, R allows you to create complex graphs, so you can generate simple one-dimensional graphs or create more sophisticated graphs like two-dimensional or multi-dimensional graphs.

### Data types:

R has 6 basic data types.

• character

• numeric

• integer

• logical

• complex

Character Datatype:

The char type in R consists of alphabets and special characters. It stores the character value or strings. The best way to declare a char value is to wrap the value inside a single or double inverted comma.

``````
char = "Quasar Community"

print(class(char))

//OUTPUT :-

"character"
``````

Numeric Datatype:

The numeric data type is decimal values. The default data type for numbers in R is a numeric data type. If we assign a decimal value to a variable x, then it will be of numeric type.

``````
x= 10

print(class(x))

//OUTPUT :-

"numeric"
``````

Integer Datatype:

The integer data type consists of all integers. One can create as well as convert a value into an integer using the as.integer() function.

``````
X= as.integer(10)

print(class(x))

//OUTPUT :-

"integer"
``````

Logical Datatype:

The logical datatype takes the value true or false. This type of variable is created as a result of comparing two other variables.

``````
x=4

y=4

z=x>y

print(z)

print(class(z))

//OUTPUT :-

TRUE

"logical"
``````

Complex Datatype:

Complex data types are a set of all complex numbers. The complex data type is used to store numbers with an imaginary component.

``````
x= 4+3i

print(class(x))

//OUTPUT :-

"complex"
``````

### How to find the data type of an object:

In order to find the data type of an object, one has to use the class() function. The syntax for doing so is mentioned below.

syntax:

class(object)

``````
# to find the data type of an object

# Logical

print(class(TRUE))

# Integer

print(class(3L))

# Numeric

print(class(10.5))

# Complex

print(class(1+2i))

# Character

print(class("12-04-2020"))

//OUTPUT :-

"logical"

"integer"

"numeric"

"complex"

"character"
``````