# Data Visualization with R

Introduction:

This blog contains information related to data visualization using R programming language and how to implement it. Moving on forward let us first know what Data Visualization is. We all know what data is; Data is nothing but collection of information. Now here arises a question that how can we visualize some piece of information? So the answer to that question is, by representing data graphically. Graphical representation of data gives us a lot of information about the data. Let us now understand what importance of data visualization is.

Importance of Data Visualization:

Visualizing the data helps us in a lot of different ways, for instance it tells us everything about the data wants to say or show to us. Visualization also tells us hidden details in the data which can be used by businessman, organizations, group of people, etc. in order to earn money. Data visualization shows us trends and patterns which are present in a data. Data visualization can be carried in multiple ways or we can say that there are multiple ways in which we can visualize the data. We can use python programming language for instance, but we are choosing a much simpler way to visualize a data, which is by using R programming language.

Description:

Since we are going to visualize data using R programming language lets us know more about it. R is an open source statistical and graphics support programming language. R is supported by R Foundation for Statistical Computing. R is of a great help when it comes to visualizing any data and representing data graphically. While visualizing the data in R we are going to use a library or tool called ggplot2. Ggplot2 is a tool which breaks a graph into semantic components such as scales and layers. Ggplot2 is a plotting package that makes it simple to create complex plots from data in data frame. There are several types in which we can visualize data, let us have a look at what are those.

Several Visualization Techniques:

There are multiple ways in which a data can be visualized which are as follows:

Histogram:

A histogram is a graphical display of a data which is by using bars of different heights and colours. In histogram each bar clusters the numbers into ranges e.g. taller bar represents large amount of data and short one represents small amount of data in the range. A histogram is used to represent continuous data.

Pie chart:

A pie chart is a circular graph which divides the data into slices like shape illustrating the numerical proportion. In a pie chart the arc length of each slice is proportional to the quantity it representes.

Box plot:

Box plot is a method from descriptive statistics which graphically depicts the group of numerical data through their quartiles. Box plot also have lines which extends from the boxes also known as whiskers, indicating variability outside the upper and lower quartiles resulting in terms box-and-whiskers plot.

Bar graph:

A bar graph or also called as bar chart is a graph or chart which represents categorical data with rectangular bars similar to histograms. In bar graph the bars have a height and lengths proportional to the values that they represents. Visually bar graphs can be plotted either horizontally or vertically, as per the requirements.

Implementation in R:

Now is the time where we look at the graphs above and create our own of our data using R programming and ggplot2 tool.

In order to implement in R we first have to install ggplot2 package in our system or in our ide. And below is the code for same:

We have downloaded the required package in R and in order to use that package we have to load it in R. And the code for loading package is as follows:

Since we’ve done loading package in our ide, we now have to perform very essential step that is transforming the data into factors:

We are now done with data manipulation, meaning converting the data as per it is required to visualize by the ggplot2 tool. Now it’s time to visualize the data.

Let’s have a look at how combination of histogram and densities or superimposed densities look like. Below is the code for the same:

O/P:

Now let us have a look on a code and graph which we are familiar with, which is bar graph:

O/P:

Conclusion:

From this blog I’m sure that many of you who have read it have known the importance of data visualization and how you too can implement it in R using the help of ggplot2 library/package. In this blog we all have seen live implementation of data visualization using R code. We also have seen different types of graphs which we can generate and which looks amazingly beautiful.