Data Exploration in R with GGPLOT2 & Standard Functions

Sharing is Caring
Share

In this post, we are going to perform high level data exploration in R programming language using GGPLOT2 and its standard plotting functions. So if you are looking on information on how to make plots and graphs in R using ggplot2 or standard r functions, you will find this post useful. You can simply change the name of the data sets and other parameters to reuse them for your project.

 

I am not going to add details about data because the purpose is to show few common and important commands.

if you have any question, please leave your question or comment.

Minimum Steps for exploration:

  1. Importing the data set into R
  2. Understanding the structure of data set
  3. Graphical exploration
  4. Descriptive statistics
  5. Insights from the data set

Data Exploration in R

please make sure you set the working directory correctly so that R can find your file. please note i have included the output for reference but you will need to print it in your machine to understand it better.

I have used GGPLOT2 and standard R functions for plotting. if you want to use GGPLOT2, you will first need to install the package.

Output

 

Summarizing Data in R for exploration

let’s summarize data and go through some of the most common parameters.

Output

 

 

Random sampling

 

random sampling with size

 

Create histograms in R with standard hist function

hist function in R lungs dataset

 

Rplot-histogram in r age years

 

 

Plot Functions in R

plot function 1

plot function 2

Plotting with GGPLOT2

if you need details about ggplot2 library, please visit my previous post on it. Click Here.

now let’s use ggplot2

qplot with ggplot2

 

let’s create a bar chart and add color by using fill and colour

ggplot 2 red

 

now create a scattered plot with ggplot2 with a fitted line

scatter plot with fitted line

let’s also add boxplot in the mix

 

Let’s create more charts using already used commands in this post:

second bar charts

As mentioned earlier, objective of this post is to show some of these useful R and ggplot2 commands. If you are looking for something specific, please share your question, i will try to answer that.

Sharing is Caring
Share
About akhilendra

Hi, I’m Akhilendra and I write about Business Analysis, Data Science, IT & Web. Join me on Twitter, Facebook & Google+

Speak Your Mind

*