-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_visualization_ggplot2-notebook.Rmd
More file actions
96 lines (66 loc) · 3.49 KB
/
data_visualization_ggplot2-notebook.Rmd
File metadata and controls
96 lines (66 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
title: 'Data Visualization with *ggplot2*'
author: 'Luca Valnegri'
date: '`r format(Sys.Date(), "%d %B %Y")`'
output:
rmdformats::readthedown:
theme: lumen
highlight: tango
code_fold: hide
css: 'https://datamaps.uk/assets/WeR/nb.css'
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Setting up
Load the *ggplot2* package. Install it if it's not found.
```{r}
if(!require(ggplot2)) install.packages('ggplot2')
library(ggplot2)
```
Load the dataset *diamond* from the [ggplot2](https://ggplot2.tidyverse.org/) package:
```{r}
data(diamonds, package = c('ggplot2'))
str(diamonds)
diamonds
```
The *diamonds* dataset contains information about 10 attributes of nearly 54,000 diamonds
Load the *Human Development Index (HDI)* dataset from the [UN Development Programme Website](http://hdr.undp.org/en/data) using the [readr](https://readr.tidyverse.org/) package:
```{r}
if(!require(readr)) install.packages('readr')
hdi <- readr::read_csv('./data/hdi.csv', skip = 1, na = c('', '..'))
str(hdi)
hdi
```
Load the *Online Retail* dataset from the [UC Irvine Machine Learning Repository](https://archive.ics.uci.edu/ml/datasets/online+retail) using the [readxl](https://readxl.tidyverse.org/) package:
```{r}
if(!require(readxl)) install.packages('readxl')
retail <- readxl::read_xlsx('./data/retail.xlsx')
str(retail)
retail
```
# Datasets
- Package Internals:
- *iris* and *mtcars* from `base`
- *msleep* from `ggplot2`
- *diamonds* from `ggplot2`
- *gapminder* from `gapminder`
- *flights* from `nycflights13`
- *storms* from `dplyr`
- [Ames Housing Dataset](https://ww2.amstat.org/publications/jse/v19n3/decock.pdf)
- [UCI Online Retail](https://archive.ics.uci.edu/ml/datasets/online+retail)
- [Human Development Index](http://hdr.undp.org/en/data) by Country
- [Corruption Perceptions Index](https://www.transparency.org/research/cpi) by Country
- [UK House Price Index](https://www.ons.gov.uk/economy/inflationandpriceindices/bulletins/housepriceindex/previousReleases)
- [UK Gender Paygap](https://gender-pay-gap.service.gov.uk/) by Business Company
- [UK Petitions](https://petition.parliament.uk/petitions/) by Constituency
- [UK Elections Results](https://researchbriefings.parliament.uk/ResearchBriefing/Summary/CBP-8647) by Constituency
- [Brexit Referendum Results](https://www.electoralcommission.org.uk/who-we-are-and-what-we-do/elections-and-referendums/past-elections-and-referendums/eu-referendum/results-and-turnout-eu-referendum) by Local Authority
- [UK Electoral Statistics](https://www.ons.gov.uk/peoplepopulationandcommunity/elections/electoralregistration/datasets/electoralstatisticsforuk) by Constituency
- [UK Population Mid-Year Estimates](https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/datasets/parliamentaryconstituencymidyearpopulationestimates) by Constituency
- [UK Food shops Ratings](https://ratings.food.gov.uk/) by Local Authority and Shop
- [Airbnb Listings](http://insideairbnb.com/get-the-data.html) by City
- [UK Crime Accident](https://data.police.uk/data/) by Lower Layer Super Output Area
- [London Cycling Scheme](https://cycling.data.tfl.gov.uk/) by Single Trip for every Bike Station
- [UK Flights Punctuality](https://www.caa.co.uk/Data-and-analysis/UK-aviation-market/Flight-reliability/Datasets/UK-flight-punctuality-data/) by Airport
- [Geography Locations and Lookups](https://geoportal.statistics.gov.uk/)