Take this

Software Development / Big Data & Analytics

Learning R for Data Visualization

Get to grips with R’s most popular packages and functions to create interactive visualizations for the web


About This Video

  • Learn how to visualize data and import/export in CSV, TXT, and Excel formats
  • Develop a professionally-featured website using the best R has to offer
  • Focus on demonstrating customized visualization on your website

In Detail

R is on the rise and showing itself as a powerful option in many software development domains. At its core, R is a statistical programming language that provides impressive tools for data mining and analysis, creating high-level graphics, and machine learning. R gives aspiring analysts and data scientists the ability to represent complex sets of data in an impressive way.

The course is structured in simple lessons so that the learning process feels like a step-by-step guide to plotting. We start by importing data in R from popular formats such as CSV and Excel tables. Then you will learn how to create basic plots such as histograms, scatterplots, and more, with the default options, which guarantees stunning results.

The second part of the course is dedicated to interactive plots. Static plots, in fact, are extremely important for scientific manuscripts, but nowadays most of our work is done online on websites and blogs, where static plots do not harness the full potential of the technology. Interactive plots, on the other hand, can improve that and allow us to present our results in more appealing and informative ways, by using the native language of the web. Do not worry though, you will not need to learn an additional programming language because this course will show you how to create stunning web plots directly from R.

In the final part of the course, the Shiny package will be extensively discussed. This allows you to create fully-featured web pages directly from the R console, and Shiny also allows it to be uploaded to a live website where your peers and colleagues can browse it and you can share your work. You will see how to build a complete website to import and plot data, plus we will present a method to upload it for everybody to use. Finally, you will revise all the concepts you've learned while having some fun creating a complete website.

By the end of the course, you will have an armour full of different visualization techniques, with the capacity to apply these abilities to real-world data sets.

Full details


  • Introducing Scientific Plotting in R
    The Course Overview
    This video provides an overview of the entire course.
    Preview of R Plotting Functionalities
    Creating professional looking plots, both static and interactive, may seem hard; however, with R we can create and fully customize plots with a few lines of code. • Use ggplot2 that can produce beautiful plots with a few lines of code • Plots are fully customizable; to obtain perfect plots every time, use customizable plots. • Create complex results using interactive plots
    Introducing the Dataset
    Often, beginners fail to properly understand their dataset before analyzing it. However, a good understanding of the origin and structure of the data is of primary importance. • Introduce the data provider, that is, EPA. • Understand the EPA network of stations • A detailed description of the data structure
    Loading Tables and CSV Files
    It is not always good to import data in R using the default settings. For doing it successfully, several parameters need to be set. • Set the working directory • Understand the important setting of the function read.table • Import the data and check the structure
    Loading Excel Files
    Importing Excel tables in R may be tricky. However, with the right explanation the proper package can be installed and everything should work out fine. • Install the package xlsx • Understand the format of the code to import Excel files • Import and check the data
    Exporting Data
    Exporting data in R may seem difficult, since we have many options to choose from. However, R has powerful exporting functions that with few options can do the job successfully. • Firstly, we need to subset our data to have something to export • Then, we can learn how to export data in R • The final step would be exporting data into multiple Excel sheets
  • Scientific Plotting in ggplot2
    Creating Histograms
    Producing elegant plots in ggplot2 may seem difficult but it is actually quite easy to do. In fact, ggplot2 takes care, by default, of most of the graphical design of the plot, meaning that we can produce beautiful histograms with just a few lines of code. • Load ggplot2 and then import the dataset • Plot a simple histogram, using the default settings. • Plot multiple distributions with faceting
    The Importance of Box Plots
    Histograms are useful for certain tasks, but for comparing several variables at once they are not the best. Box plots can be used instead, since they allow the comparison of the distribution of multiple variables side by side. • Explain what a box plot is and what does it represents • Create multiple box plots with just two lines of code • Order the plot to achieve better results
    Plotting Bar Charts
    Categorical variables are invariably difficult to visualize in meaningful ways. Bar charts are important for plotting categorical variables and defining their characteristics. • Learn bar charts • Create simple bar charts in ggplot2 • Learn how to automatically order a data.frame and plot ordered bar charts
    Plotting Multiple Variables – Scatterplots
    In many cases, we are interested in comparing multiple variables at once and checking their correlation. Scatterplots allow us to do just that and are an important tool in a data analyst's toolbox. • Describe the importance of scatterplots • Create simple scatterplots in ggplot2 • Create more complex visualization by tweaking some basic options
    Dealing with Time – Time-series Plots
    In many cases, the variable time is underestimated. However, time-series are extremely useful to determine the temporal pattern of a variable. • Understand the structure of time-series plots • Plot a simple time-series plot in ggplot2 • Customize the plots with color and size
    Handling Uncertainty
    Many datasets are affected by uncertainty and people not always know how to show this in plots. This video will present ways to solve this and take uncertainty into account. • Understand how to handle uncertainty • Present simple ways to include uncertainty in bar-charts • Present the scatterplots with double error bars
  • Customizing Plots
    Changing Theme
    By default, ggplot2 creates plots with a grayish background, and without axes lines and white gridlines. This is not the standard look you normally find in scientific manuscripts. • Explain the graphical elements of the standard theme • Change the default theme • Explore the differences between the default theme and the others
    Changing Colors
    The default color scale is not always appropriate to spot all the differences in the data we are trying to plot. In many cases, we have to change it so that our plots can become more informative. • Change the default two colors for plotting continuous variables • Explore ways to include more colors in the color scale • Present discrete color scale for categorical variables
    Modifying Axis and Labels
    ggplot2 uses the names of the columns as labels, meaning that if these are not self-explanatory, the plot will not provide a good framework to understand its meaning. By adding some lines of code, we can customize the plot in order to change the labels and make it clearer. • Add a title for the plot • Change the title of the legend • Change the axes labels
    Adding Supplementary Elements
    The default plots created by ggplot2 lack several elements that in many cases are useful to provide additional information to viewers. However, there are simple functions that can be used to add supplementary elements to the plot. • Add the trend lines to scatterplots • Learn how to add vertical and horizontal lines to plots • Customize the lines
    Adding Text Inside and Outside of the Plot
    In many cases, it is crucial to be able to include textual labels on plots to provide viewers with additional information. This can be done in ggplot2 in both static and dynamic ways. • Add fixed text labels • Add dynamic textual labels • Add text outside the plot and change the axis labels
    With the function facet_wrap, it is only possible to create a grid of plots of the same type. However, in some cases, it is necessary to create side-by-side graphs with diverse plots. This can be done in the package gridExtra. • Review the facet_wrap function • Install the gridExtra package • Create the multi plots
  • Exporting Plots
    Exporting Plots as Images
    We could easily save our plots as images directly from R Studio. This way of saving however, does not provide much flexibility. If we want to customize our images, we need to learn how to export plots from the R code. • Create an object with the plot we want to save • Learn the basics of the ggsave function • Change the size of the image
    Adjusting the Page Size
    The default size that ggplot2 uses to save plots is ideal for most of our needs, such as embedding plots in Word documents. However, in some cases, we may need to specify a particular page size for our plots, which can be easily done with the option paper. • Specify the page size • Rotate the page • Specify other options
  • Interactive Plots in rCharts
    Getting Started with Interactive Plotting
    Static plots are the standard for publishing in traditional media, such as journal papers. However, the world is moving towards an internet-based presentation of results and even scientific journals are quickly adapting it. Many now offer the possibility of including interactive plots. In R, we can create plots for the Web with the rCharts package, which is a bit more difficult to install than ggplot2. • Explain the rCharts package • Install devtools • Install rCharts from GitHub
    Creating Interactive Histograms and Box Plots
    rCharts features a syntax more similar to standard plotting in R than what we saw with ggplot2. However, it is easy to pick up by showing simple examples and then including additional details. • Explain the syntax of rCharts • Include more details • Add JavaScript functions for more flexibility
    Plotting Interactive Bar Charts
    Even though we know nothing about HTML and CSS, we can still obtain beautiful bar-charts using templates created by other users. • Plot basic interactive bar charts • Add axis labels • Use a template for an elegant finish
    Creating Interactive Scatterplots
    If too many data points are present in our dataset, scatterplot visualization may become very confusing in static plots. However, in interactive plots this limitation no longer applies, since we can select to visualize only some datasets. • Create basic interactive scatterplots • Understand the interactivity • Add elements and controls
    Developing Interactive Time-series Plots
    Time-series plots are a great way to visualize the temporal pattern of a variable. However, sometimes we cannot fully understand the exact date of each point based only on the values on the x axis. Interactive visualization can solve this problem by adding tooltips in which we can take a look at the raw data. • Set the data in the correct format • Plot a basic time-series plot • Add elements
  • Creating a Website with Shiny
    Getting Started with Shiny
    Shiny is a package to build fully featured websites from scratch in R. The way it communicates between the user interface and the server may seem difficult to understand. However, with some explanation, understanding Shiny becomes very easy and intuitive. • Introduce the Shiny package • Explain the tutorial and examples • Understand the basic structure of a Shiny website
    Creating a Simple Website
    Understanding the structure of a Shiny website is very important. However, presenting it from a website is not enough for the viewers to replicate it. Therefore, in this video, we are going to create a simple website with data and plots we already used, to further help viewers. • Understand the basic structure of Shiny • Add elements to UI and Server • Test the website
    File Input
    If we plan to upload our Shiny website on-line, we need to implement a way for users to upload their own data. In this video, we are going to show how to do just that. • Importing files in Shiny • Simple code to do it • Add a separator for more flexibility
    Conditional Panels – UI
    One of the key components of a successful website is the ability to respond to users’ interactions. This can be achieved with conditional panels, which change the UI based on users’ interactions. • Explain conditional panels • Understand UI modifications • Apply server modifications
    Conditional Panels – Servers
    One of the key components of a successful website is the ability to respond to users’ interactions. This can be achieved with conditional panels, which change the UI based on users’ interactions. • Modify server side modifications • Keep track of the IDs • Recognize variables automatically
    Deploying the Site
    So far, we have looked at ways to create and add elements to a Shiny website. However, sooner or later, this website needs to be deployed on the Internet so that everybody can use it. Here, you will learn how to do it using a free account on shinyapps.io. • Separate ui.r and server.r • Add plots to the script • Finally, we deploy the site.


  • Data Visualization
  • Statistics

Similar Courses

More Courses by this Instructor