boosting your data analysis skills with data visualisation ... y… · from r for data science, by...
TRANSCRIPT
![Page 1: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/1.jpg)
Boosting your data analysis skills with data visualisation and ggplot2
Direction Access to and Reuse of Public Information
Unit EU Open Data and CORDIS
Sector EU Open Data
Publications Office of the European Union
2 rue Mercier, 2985 Luxembourg, LUXEMBOURG • Tel. +352 2929- • Fax +352 2929-
![Page 2: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/2.jpg)
The context
This training course is organized in the scope of OP project within the
ISA2 programme
ISA2 supports the development of digital solutions enabling public administrations,
businesses and citizens in Europe to benefit from interoperable cross-border and cross-
sector public services.
How OP is involved in ISA2?
OP is aiming at developing open data related activities in the areas of:
Data visualisation
Linked open data
Persistent identification
![Page 3: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/3.jpg)
Upcoming training & workshop sessions
TopicType of
session
Lux
+ webexBxl
Telling your story through data visualisation Training 25/06 28/06
Making great online data visualisations without
coding
workshop 26/06 -
Going beyond bars and lines: practising non-
standard data visualisation
Training 24/09 Sep-Oct
Making data visualisations like a pro: D3.js Workshop 25/09 -
Applying data visualisation best practices in real
use cases
workshop 24/10 -
and webinars (topic like for the trainings) … stay tuned!
Materials will be published on https://data.europa.eu/euodp/en/knowledge-center
![Page 4: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/4.jpg)
Data visualization events in 2019
EU DataViz 2019 – Data Visualisation for the Public Sector
• Date: 12 November 2019
• Venue: European Convention Center - Luxembourg
• Website: https://publications.europa.eu/eudataviz
• e-mail: [email protected]
EU Datathon 2019
• Date: 13 June 2019
• Venue: Residence Palace - Brussels
• Website: https://publications.europa.eu/eudatathon
• e-mail: [email protected]
![Page 5: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/5.jpg)
Where to find the information about our
training workshop and webinar sessions?
Visit our data visualisation community to find all the information about previous and
upcoming sessions at:
https://webgate.ec.europa.eu/fpfis/wikis/display/EUODDVC/Data+Visualisation+-
+Training+Package+2019
![Page 6: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/6.jpg)
Agenda
Introduction
Visualisation in data analysis
ggplot, R and RStudio
Coffee break
Data diagnostics
Visualising distributions
Lunch
Visualising covariation
Visualising multiple dimensions
Coffeebreak
Visualising time series
Saving and sharing visualisations
Other tools
Q&A
09:00
10:30
12:00 – 13:00
14:30
16:30
![Page 7: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/7.jpg)
INTRODUCTION
1.
![Page 8: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/8.jpg)
Participants
Institution/DG and role?
Experience with coding, R and ggplot2?
Expectations for today?
![Page 9: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/9.jpg)
VISUALISATION IN DATA
ANALYSIS?
2.
![Page 10: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/10.jpg)
EDA
What is it?
![Page 11: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/11.jpg)
EDA
What is it?
John Tukey "The simple graph has brought
more information to the data
analyst’s mind than any other
device"
"The greatest value of a picture
is when it forces us to notice
what we never expected to see"
![Page 12: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/12.jpg)
EDA
What is it?
Wikipedia "EDA is for seeing what the data
can tell us beyond the formal
modeling or hypothesis testing
task"
![Page 13: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/13.jpg)
EDA
What is it?
From R for Data
Science, by Hadley
Wickham
Hadley Wickham is the
creator of ggplot2
Your goal during EDA is to develop an
understanding of your data.
EDA is an iterative cycle. You
generate questions about your data
search for answers by visualising,
transforming, and modelling your data
use what you learn to refine your
questions and/or generate new questions
![Page 14: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/14.jpg)
EDA
Tool requirements
Fast
Flexible
Integrates with data
manipulation
Slice & dice data
Iterate over visualisations
Good defaults
Many visualisation types
Combine visualisations
The Tidyverse
![Page 15: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/15.jpg)
EDA
R Tidyverse
tidyverse.org
Declaritavely create graphics
Grammar for data manipulation
Get data in tidy format
![Page 16: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/16.jpg)
GGPLOT2
3.
![Page 17: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/17.jpg)
ggplot2
Grammar of graphics
R package for making
visualisations
Based on the
"Grammar of Graphics"
by Leland Wilkinson
"A a tool that enables
us to concisely
describe the
components of a
graphic"
![Page 18: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/18.jpg)
ggplot2
Grammar of graphics
An example of how a
visualisation is
constructed from a
data set
![Page 19: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/19.jpg)
ggplot2
Grammar of graphics
Grammar of graphics
specification
![Page 20: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/20.jpg)
ggplot2
Grammar of graphics
Grammar of graphics:
result
![Page 21: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/21.jpg)
ggplot2
Data
Plot
Used
aesthetics
Data in aesthetic
space
Ggplot2 is an
implementation of
the grammar of
graphics in R
How do we go
from data to a
visualisation in
ggplot2?
![Page 22: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/22.jpg)
ggplot2
Data
Plot
ggplot(data=Data,
aes(x=A, y=B, shape=D)) +
geom_point()
Map data to
aesthetics of
geometries
![Page 23: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/23.jpg)
Demo
3-ggplot-intro.R
library(ggplot2)
exampledata <- read.csv("ggplot-example-
data.csv")
View(exampledata)
ggplot(data = exampledata, aes(x = A, y = B,
shape = D)) + geom_point()
![Page 24: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/24.jpg)
ggplot2
Components of a
ggplot2 plot Data
Scales (map data to aesthetics)
Geometric objects
Coordinate system (a pie chart
is just a bar chart in polar
coords)
Statistics
Facets
![Page 25: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/25.jpg)
R & RSTUDIO
4.
![Page 26: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/26.jpg)
R
Free, open source
programming language
Initially for statistics
and graphics
Today: maps,
publishing documents,
interactive
dashboards, blogging,
etc.
Big community:
learning resources,
packages, events
![Page 27: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/27.jpg)
RStudio
Free, open source
client for R
rstudio.com
![Page 28: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/28.jpg)
rstudio.cloud
Rstudio online
Runs in the browser,
no installation needed
Share R projects
rstudio.cloud
![Page 29: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/29.jpg)
rstudio.cloud
Set up
Go to rstudio.cloud
Click "Sign Up" and create an
account
Go to
rstudio.cloud/project/351652
Click "Save a permanent copy"
![Page 30: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/30.jpg)
![Page 31: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/31.jpg)
Source
(aka Editor)
Console
Environment
Files
Plots
Packages
Help
![Page 32: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/32.jpg)
RStudio interface
Source Write scripts
Preview data
Uses tabs
![Page 33: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/33.jpg)
Source
(aka Editor)
Console
Environment
Files
Plots
Packages
Help
![Page 34: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/34.jpg)
RStudio interface
Console Execute R code
Output of code
Errors and warnings
![Page 35: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/35.jpg)
Source
(aka Editor)
Console
Environment
Files
Plots
Packages
Help
![Page 36: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/36.jpg)
RStudio interface
Environment Loaded objects
History of commands
"Import dataset" wizard
![Page 37: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/37.jpg)
Source
(aka Editor)
Console
Environment
Files
Plots
Packages
Help
![Page 38: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/38.jpg)
RStudio interface
Files
Plots
Packages
Help
File explorer
ggplot output
Installed packages
Documentation of functions and packages
![Page 39: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/39.jpg)
R basics
Load data
Assign
Inspecting data
Get help
"Import dataset" wizard
read.csv("mydatafile.csv")
eurostat::get_eurostat("ilc_hch10")
x <- 5
mydataframe <- read.csv(...)
View(...)
head(...)
Inspect object
?read.csv
?head
![Page 40: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/40.jpg)
R & Rstudio basics
Packages
Run code
Saving script
install.packages("ggplot2")
library(ggplot2)
"Run" button in Source pane
Using the console
File => Save as
.R files
![Page 41: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/41.jpg)
Exercise
4-load-data.R
View(...)
read.csv(...)
library(...)
readxl::read_excel(...)
?...
eurostat package
open data in the data viewer
load csv files
load (installed) package
load Excel files and sheets
open the documentation
find and load eurostat data
![Page 42: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/42.jpg)
DATA PROFILING
5.
![Page 43: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/43.jpg)
Data profiling
A first glimpse of the
data How big is the data?
What are the data types?
Missing data? Errors?
Starting to understand the data
![Page 44: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/44.jpg)
Data profiling
Missing data
Inspect
Run the data frame
NA values
Check the object under Environment
Data frame will be outputted in the console
![Page 45: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/45.jpg)
Exercise
5-1-data-profiling.R
ncol(...)
nrow(...)
typeof(...)
str(...)
summary(...)
visdat::vis_dat(...)
number of columns
number of lines
data type of a column
compact display of R object
summary statistics
visual profile of dataframe
![Page 46: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/46.jpg)
Exercise
5-2-check-assumptions.R
geom_col()
dplyr::filter()
bar and column charts
from the dplyr package, filter
data on 1 or more conditions
![Page 47: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/47.jpg)
VISUALISING DISTRIBUTIONS
6.
![Page 48: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/48.jpg)
Visualising
distributions
1 numerical column
1 optional categorical
column
Range of the distribution
Shape of the distribution
(symmetrical, bimodal, long
tails, ...)
Central values
Outliers
![Page 50: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/50.jpg)
Distributions
Points
The easiest way to
visualise a
distribution: plotting
each value
geom_point()
If you have overlap:
use alpha or
geom_jitter()
![Page 51: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/51.jpg)
Distributions
Boxplots
geom_boxplot()
ggplot calculates the
medians, quartiles and
outliers for us
![Page 52: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/52.jpg)
Exercise
6-1-distributions-points-boxplots.R
geom_point()
geom_boxplot()
geom_jitter()
geom_text()
geom_1() + geom_2()
plot points (circles, symbols)
plot boxplots
add jittering
plot text
combine geoms
![Page 53: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/53.jpg)
Distributions
Boxplots alternatives
![Page 54: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/54.jpg)
Distributions
Histograms
geom_histogram()
ggplot does the
counting for us
binwidth/bins
parameters is very
important: try
different bin sizes
![Page 55: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/55.jpg)
Distributions
Frequency polygons
geom_freqpoly()
Same as histogram,
but with lines instead
of bars
Better suited to
compare distributions
between different
categories
![Page 56: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/56.jpg)
Distributions
Density plot
geom_density()
Smooth version of
geom_freqpoly()
Use when underlying
data is smooth
![Page 57: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/57.jpg)
Distributions
Violin plot
geom_violin()
Compact, mirrored
version of
geom_density()
![Page 58: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/58.jpg)
Exercise
6-2-distributions-othergeoms.R
geom_histogram()
geom_freqpoly()
geom_density()
geom_violin()
plot histograms
plot frequency polygons
plot density estimates
plot violin plots
![Page 59: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/59.jpg)
VISUALISING COVARIATION
7.
![Page 60: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/60.jpg)
Visualising
covariation
Two numerical
variables
Optionally one
categorical variable
Identify correlations
Detect outliers
![Page 61: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/61.jpg)
Covariation
Scatterplots
geom_point()
geom_text()
geom_label()
Use geom_jitter() for
discrete or categorical
variables
![Page 62: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/62.jpg)
Covariation
Scatterplots
Overcome overplotting
by binning with
geom_bin2d()
geom_hex()
Or use transparency:
alpha
![Page 63: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/63.jpg)
Exercise
7-1-scatterplots.R
geom_point()
geom_bin2d()
geom_hex()
scale_x_continuous()
scale_fill_continuous()
plot points
bin points in rectangles
bin points in hexagons
customise continuous scale
customise color scale
![Page 64: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/64.jpg)
Exercise: Why visualise?
7-2-anscombe.R
Dataset "anscombe”
View(anscombe)
Check the means with summary(anscombe)
Calculate some stats:
sd(anscombe$x1)
cor(anscombe$x1,
anscombe$y1)
Now make scatterplots:
x1 ~ y1
x2 ~ y2
x3 ~ y3
x4 ~ y4
What do you see?
![Page 65: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/65.jpg)
EDA
Why visualise?
Datasaurus
![Page 66: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/66.jpg)
Covariation
Heatmaps
2 categorical or
discrete variables + 1
numerical variable
geom_tile()
![Page 67: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/67.jpg)
Exercise
7-3-heatmaps.R
geom_tile() plot rectangles
![Page 68: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/68.jpg)
MULTIDEMENSIONAL DATA
8.
![Page 69: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/69.jpg)
Multidimensional
Add aesthetics
geoms have many
aesthetics. For example,
geom_point()
understands the
following:
x*
y*
color
fill
group
shape
size
stroke
![Page 70: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/70.jpg)
Exercise: Why visualize?
8-1-gapminder.R
+ aes()
scale_x_log10()
scale_size_area()
Add aesthetic to a plot
Logarithmic scale
Size scale
![Page 71: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/71.jpg)
Multidimensional
Facetting
Make small multiple
charts by facetting
plots with
facet_wrap() and
facet_grid()
Free vs fixed scales
![Page 72: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/72.jpg)
Exercise
8-2-facetting.R
facet_wrap()
facet_grid()
plot split into small multiples for 1
variable
plot split into small multiples for 2
variables
![Page 73: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/73.jpg)
Multidimensional
Parallel
coordinates
Plot many dimensions
and see correlation
between them
GGally::ggparcoord()
Add boxplots
![Page 74: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/74.jpg)
Exercise: Why visualize?
8-3-parallel-coordinates.R
GGally::parcoord() plot parallel coordinate plot
![Page 75: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/75.jpg)
Multidimensional
Multiple views &
interactivity
Shiny package Filters & interaction
Multiple visualisations
Example
Coordinated views
Example
![Page 76: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/76.jpg)
VISUALISING TIME SERIES
9.
![Page 77: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/77.jpg)
Time series
geom_line()
geom_line() with
group or color
aesthetic
geom_area()
scale_x_time()
scale_x_date()
![Page 78: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/78.jpg)
Exercise
9-time-series.R
geom_line()
geom_area()
scale_x_date()
plot line charts
plot area charts
![Page 79: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/79.jpg)
SAVING AND SHARING
VISUALISATIONS
10.
![Page 80: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/80.jpg)
Saving
ggsave()
Plots panel => Export
ggsave()
save a plot to your project/hard drive
file formats
dpi
units
![Page 81: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/81.jpg)
Sharing
Rmarkdown
Mix text, R-code and
R-output
Output to html, Word,
Powerpoint, etc.
File => New file => R
Markdown...
Example(preparation for Why Budapest, Lithuania and Warsaw split
themselves in two)
![Page 82: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/82.jpg)
OVERVIEW OF OTHER TOOLS
11.
![Page 83: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/83.jpg)
Visual EDA
Other tools
Python:
pandas, seaborn, matplotlib
altair
Without coding:
Qlik
Tableau
![Page 84: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/84.jpg)
Q&A
![Page 85: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/85.jpg)
Resources
Grammar of Graphics
A layered grammar of graphics
R & EDA
R for Data Science
ggplot2
Tidyverse: ggplot2
Data visualization: A practival introduction
Fundamentals of Data Visualisation
ggplot2 Cheat Sheet
![Page 86: Boosting your data analysis skills with data visualisation ... y… · From R for Data Science, by Hadley Wickham Hadley Wickham is the creator of ggplot2 Your goal during EDA is](https://reader034.vdocuments.us/reader034/viewer/2022042222/5ec895ae86ef5541f57bafb6/html5/thumbnails/86.jpg)
Upcoming training & workshop sessions
TopicType of
session
Lux
+ webexBxl
Telling your story through data visualisation Training 25/06 28/06
Making great online data visualisations without
coding
workshop 26/06 -
Going beyond bars and lines: practising non-
standard data visualisation
Training 24/09 Sep-Oct
Making data visualisations like a pro: D3.js Workshop 25/09 -
Applying data visualisation best practices in real
use cases
workshop 24/10 -
and webinars (topic like for the trainings) … stay tuned!
Materials will be published on https://data.europa.eu/euodp/en/knowledge-center