• Welcome !
  • Mail us: contact@analytickast.com
Analytickast.com Analytickast.com
  • Home
  • Blog
  • Coaching
    • Course Dashboard
    • Instructor Registration
    • Student Registration
  • Shop Now
  • Contact Us
  • My account
    • Cart
    • Checkout
  • Log In

Signup

Introduction to R Graphics Using ggplot2

Introduction to R Graphics Using ggplot2

Exploratory data analysis is crucial for understanding and visualizing raw data. In this introduction to R graphics, learn how to use ggplot2 to do just that.

Data visualization is an integral step in a data science process. At every step in a data science pipeline, data is visualized in one form or another. It is used to understand raw data in a process commonly known as exploratory data analysis, evaluating the accuracy of a model and providing results for easy interpretation. A good graphic design helps clarify meaning and ease communication. A powerful aesthetic also eases the visual navigation to mix the power of art and functionality.

Though R’s standard graphics package is strong for analyzing the data, it lacks essential aesthetic. The ggplot2 package has an entirely different approach to statistical plots. It is based on the book The Grammar of Graphics by Leland Wilkinson and was developed by Hadley Wickham. It follows a layered approach to give plots a better look with robust functionality.

The layered approach can be described as follows:

  • Data layer: The dataset to be plotted.
  • Aesthetics: Used to set data mappings and scales onto which we plot the data, i.e. what attribute goes on the X-axis and what goes on the Y-axis.
  • Geometrics: Used to define visual elements and represents the overall look of the layer, i.e. a line graph, bar graph, point graph, etc.
  • Statistics: An optional layer used to summarize data, i.e. binning or smoothing to draw regression lines.

Below is a quick method to plot data using ggplot2:

  1. The data is mapped to aesthetic attributes.
  2. A geom layer is then added to define the kind of plots we want to form.
  3. If we need some summary functions to be added to the graph, a statistics layer is appended.

Below is a simple example for illustrating a plot drawn using ggplot2:

library(ggplot2)
data(mtcars)
ggplot(data=mtcars, # Data 
  aes(x=disp,y=mpg,color=am))+ # Aesthetic
geom_point()+ # Geometry
stat_smooth(method="lm")  # Statistics

Image title

As we can see in the code, the main function ggplot defines the mapping between the data and plot axis. Next, different components are added into each layer to determine the type of graph and to add a regression line.

This is just a tidbit of what ggplot2 can offer. Below are some resources that can be handy for creating visualizations using this package:

  • ggplot2 Quick Reference
  • How to get geoms in ggplot
  • Build a plot layer-by-layer
Categories: Machine Learning
Prev Post
Next Post

Add your Comment

Recent Posts

  • Insights on Data Science Automation for Big Data and IoT Environments
  • The Changing Landscape: Data Science Trends
  • Streamline the Machine Learning Process Using Apache Spark ML Pipelines
  • Dive Deep Into Deep Learning
  • CEP Patterns for Stream Analytics

Recent Comments

    Archives

    • June 2020

    Post Categories

    • Business Analytics
    • Machine Learning
    • Popular Content

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org

    About AnalyticKast

    Author

    Our goal is to provide easy access to people on data technologies related information to thrive in this digital economy.

    Latest Posts

    Insights on Data Science Automation for Big Data and IoT Environments

    Insights on Data Science Automation for Big Data and IoT Environments

    June 30, 2020

    The Changing Landscape: Data Science Trends

    June 30, 2020

    Streamline the Machine Learning Process Using Apache Spark ML Pipelines

    June 30, 2020

    About Analytickast

    One-stop knowledge services platform that supports individuals connect the dots between technologies and management to build data products. Our goal is to provide easy access to people on data technologies related information to thrive in this digital economy.

    Blogs

    • Business Analytics
    • Machine Learning
    • Popular Content

    Quick Links

    • Home
    • Blog
    • Coaching
    • Shop Now
    • Contact Us
    • My account
    • Log In

    Our Videos

    All Rights Reserved © 2020. - www.analytickast.com .

    • Privacy Policy
    • Legal Disclaimer
    • Terms of Use

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.