We have already learned about how we can create meaningful data visualizations in R using the Base Graphics package. In this section, we will learn about how we can create even more powerful data graphics using an R package called ggplot2. What is ggplot2? The ggplot2 package is a very popular alternative to the base graphics […]

# Data Science

## Adding Details and Features to R Plots

We’ve already seen how we can enhance the plots created in R by adding title, axis labels, legends, etc. Let’s learn about a few more enhancements. Adding Vertical/Horizontal Lines to the Graph You may want to add a vertical or a horizontal line to your graph at a certain axis point. This can be done […]

## Plotting Multiple Datasets on One Chart in R

It’s a common scenario to plot multiple datasets together on a single graph. For example, we may want to plot the daily returns from multiple stocks on a single chart to understand how they trend vis-a-vis each other. Similarly, we may want to plot multiple normal distribution curves with different mean and standard deviations. To […]

## Creating a Line Chart in R

In R, we can create a line plot using the same plot() function by adding a plot type of “l”. This will plot the (x,y) paired observations and connect them with lines. Let’s generate our own data for this lesson. We will use the rnorm() function to generate a set of 100 random numbers that follow a normal distribution. […]

## Creating a Bar Chart in R

In R, we can create a bar plot using the barplot() function. A Bar Plot or Bar Graph is primarily used to compare values. It presents grouped data using rectangular bars whose lengths are proportional to the values that they represent. Let’s take our Product Sales data where we have the Revenue and Gross Margin for each […]

## Create a Scatter Plot in R with Multiple Groups

Let’s say you have Sales Orders data for a sports equipment manufacturer and you want to plot the Revenue and Gross Margins on a scatter plot. However, you also have a ProductLine column that contains information about the product category and you want to distinguish the x,y points by the ProductLine. We can do so […]

## How to Create a Scatter Plot in R

When you start analyzing a new dataset, your first requirement would be to know the variables in the dataset and the relationship between them. A scatter plot is the perfect place to start with. It is the quickest way to view the relationship between any two variables x and y. You can create a scatter […]

## Accessing Built-in Datasets in R

R comes with many built-in datasets which are quite useful while learning R. To begin learning the basics of data visualization in R, we will make use of some of these datasets. Datasets in the ‘datasets’ package Many datasets are included in a package called datasets which is distributed with R so these datasets are instantly available […]

## Graphic Systems in R

If you want to plot a graph in R for your own consumption, it is pretty easy and you can generally do it with a few lines of code. However, if you are creating the graph for others consumption and want full control over all aspects of the graph, it will require some effort. The […]

## Visualization in Data Science

The advent of data science has opened doors to making discoveries from data in new and innovative ways. By combining statistics, computer science, applied mathematics and data visualizations, a data scientist or analyst can turn vast amounts of complex data into meaningful insights and new knowledge. The fundamental purpose of any data science project is […]