SlideShare a Scribd company logo
1 of 1
Download to read offline
Group Cases
Search and download
www
www
eurostat and plots
.
.
wwwwww
wwwwww
www ww
wwwww
R tools to access open data
from Eurostat database
The eurostat package
Data in the Eurostat database is stored in tables. Each table has an
identifier, a short table_code, and a description (e.g. tsdtr420 - People
killed in road accidents).
Key eurostat functions allow to find the table_code, download the
eurostat table and polish labels in the table.
library("eurostat")
query <- search_eurostat("road", type = "table")
query[1:3,1:2]
## title code
## 1 Goods transport by road ttr00005
## 2 People killed in road accidents tsdtr420
## 3 Enterprises with broadband access tin00090
The get_eurostat() function returns tibbles in the long format. Packages
dplyr and tidyr are well suited to transform these objects. The ggplot2
package is well suited to plot these objects.
t1 <- get_eurostat("tsdtr420", filters =
list(geo = c("UK", "FR", "PL", "ES", "PT")))
library("ggplot2")
ggplot(t1, aes(x = time, y = values, color = geo,
group = geo, shape = geo)) +
geom_point(size = 2) +
geom_line() + theme_bw() +
labs(title="Road accidents", x = "Year", y = "Victims")
eurostat and maps
This onepager presents the eurostat package
Leo Lahti, Janne Huovari, Markus Kainu, Przemyslaw Biecek 2014-2017 package version 2.2.43 URL: https://github.com/rOpenGov/eurostat
Find the table code
Thesearch_eurostat(pattern,...)functionscansthedirectoryofEuro-
stat tables and returns codes and descriptions of tables that match
pattern.
Download the table
The get_eurostat(id, time_format = "date", filters = "none", type =
"code", cache = TRUE, ...) function downloads the requested table
from the Eurostatbulkdownloadfacility or from TheEurostatWebServi-
ces JSON API (if filters are defined). Downloaded data is cached (if
cache=TRUE). Additional arguments define how to read the time
column (time_format) and if table dimensions shall be kept as codes
or converted to labels (type).
dat <- get_eurostat(id="tsdtr420", time_format="num")
head(dat)
## unit sex geo time values
## 1 NR T AT 1999 1079
## 2 NR T BE 1999 1397
## 3 NR T CZ 1999 1455
## 4 NR T DK 1999 514
## 5 NR T EL 1999 2116
## 6 NR T ES 1999 5738
Add labels
The label_eurostat(x, lang = "en", ...) gets definitions for Eurostat
codes and replace them with labels in given language ("en", "fr" or
"de").
dat <- label_eurostat(dat)
head(dat)
## unit sex geo time values
## 1 Number Total Austria 1999 1079
## 2 Number Total Belgium 1999 1397
## 3 Number Total Czech Republic 1999 1455
## 4 Number Total Denmark 1999 514
## 5 Number Total Greece 1999 2116
## 6 Number Total Spain 1999 5738
library("dplyr")
t2 <- t1 %>% filter(time == "2014-01-01")
ggplot(t2, aes(geo, values, fill=geo)) +
geom_bar(stat = "identity") + theme_bw() +
theme(legend.position = "none")+
labs(title="Road accidents in 2014", x="", y="Victims")
There are three function to work with geospatial data from GISCO. The
get_eurostat_geospatial() returns preprocessed spatial data as sp-ob-
jects or as data frames. The merge_eurostat_geospatial() both down-
loads and merges the geospatial data with a preloaded tabular data. The
cut_to_classes() is a wrapper for cut() - function and is used for categori-
zing data for maps with tidy labels.
Fetch and process data
library("eurostat")
library("dplyr")
fertility <- get_eurostat("demo_r_frate3") %>%
filter(time == "2014-01-01") %>%
mutate(cat = cut_to_classes(values, n=7, decimals=1))
mapdata <- merge_eurostat_geodata(fertility,
resolution = "20")
head(select(mapdata,geo,values,cat,long,lat,order,id))
## geo values cat long lat order id
## 1 AT124 1.39 1.3 ~< 1.5 15.54245 48.90770 214 10
## 2 AT124 1.39 1.3 ~< 1.5 15.75363 48.85218 215 10
## 3 AT124 1.39 1.3 ~< 1.5 15.88763 48.78511 216 10
## 4 AT124 1.39 1.3 ~< 1.5 15.81535 48.69270 217 10
## 5 AT124 1.39 1.3 ~< 1.5 15.94094 48.67173 218 10
## 6 AT124 1.39 1.3 ~< 1.5 15.90833 48.59815 219 10
40
50
60
−10 0 10 20 30 40
long
lat
0.9 ~< 1.3
1.3 ~< 1.5
1.5 ~< 1.7
1.7 ~< 1.9
1.9 ~< 2.3
2.3 ~< 3.1
3.1 ~< 4.5
library("ggplot2")
ggplot(mapdata, aes(x = long, y = lat, group = group))+
geom_polygon(aes(fill=cat), color="grey", size = .1)+
scale_fill_brewer(palette = "RdYlBu") +
labs(title="Fertility rate, by NUTS-3 regions, 2014",
subtitle="Avg. number of live births per woman",
fill="Total fertility rate(%)") + theme_light()+
coord_map(xlim=c(-12,44), ylim=c(35,67))
Draw a cartogram
The object returned by merge_eurostat_geospatial() are ready to be
plotted with ggplot2 package. The coord_map() function is useful to set
the projection while labs() adds annotations o the plot.
● ●
●
● ●
●
●
●
●
●
●
●
●
●
● ●
2000
4000
6000
8000
2000 2005 2010 2015
Year
Victims
geo
● ES
FR
PL
PT
UK
Road accidents
0
1000
2000
3000
ES FR PL PT UK
Victims
Road accidents in 2014
40
50
60
−10 0 10 20 30 40
long
lat
Total fertility rate(%)
0.9 ~< 1.3
1.3 ~< 1.5
1.5 ~< 1.7
1.7 ~< 1.9
1.9 ~< 2.3
2.3 ~< 3.1
3.1 ~< 4.5
Avg. number of live births per woman
Fertility rate, by NUTS−3 regions, 2014
CC BY Przemyslaw Biecek
https://creativecommons.org/licenses/by/4.0/

More Related Content

What's hot

Plot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onPlot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onDr. Volkan OBAN
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..Dr. Volkan OBAN
 
Excel macro for solving a polynomial equation
Excel macro for solving a polynomial equationExcel macro for solving a polynomial equation
Excel macro for solving a polynomial equationUpendra Lele
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Dr. Volkan OBAN
 
Cassandra model
Cassandra modelCassandra model
Cassandra modelzqhxuyuan
 
Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303Namgee Lee
 
Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheetGil Cohen
 
Артём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data AnalysisАртём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data AnalysisSpbDotNet Community
 
12c Mini Lesson - Invisible Columns
12c Mini Lesson - Invisible Columns12c Mini Lesson - Invisible Columns
12c Mini Lesson - Invisible ColumnsConnor McDonald
 
PYTHON PROGRAMS FOR BEGINNERS
PYTHON PROGRAMS FOR BEGINNERSPYTHON PROGRAMS FOR BEGINNERS
PYTHON PROGRAMS FOR BEGINNERSJEETPRATAPSINGH
 

What's hot (18)

Plot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onPlot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,on
 
Seminar PSU 10.10.2014 mme
Seminar PSU 10.10.2014 mmeSeminar PSU 10.10.2014 mme
Seminar PSU 10.10.2014 mme
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..
 
Basic Calculus in R.
Basic Calculus in R. Basic Calculus in R.
Basic Calculus in R.
 
Excel macro for solving a polynomial equation
Excel macro for solving a polynomial equationExcel macro for solving a polynomial equation
Excel macro for solving a polynomial equation
 
Array
ArrayArray
Array
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
 
Cs101 endsem 2014
Cs101 endsem 2014Cs101 endsem 2014
Cs101 endsem 2014
 
C questions
C questionsC questions
C questions
 
Cassandra model
Cassandra modelCassandra model
Cassandra model
 
Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303
 
Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheet
 
Артём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data AnalysisАртём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data Analysis
 
12c Mini Lesson - Invisible Columns
12c Mini Lesson - Invisible Columns12c Mini Lesson - Invisible Columns
12c Mini Lesson - Invisible Columns
 
Matlab differential
Matlab differentialMatlab differential
Matlab differential
 
Chapter2
Chapter2Chapter2
Chapter2
 
Revision1schema C programming
Revision1schema C programmingRevision1schema C programming
Revision1schema C programming
 
PYTHON PROGRAMS FOR BEGINNERS
PYTHON PROGRAMS FOR BEGINNERSPYTHON PROGRAMS FOR BEGINNERS
PYTHON PROGRAMS FOR BEGINNERS
 

Similar to Eurostat cheatsheet

Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisUniversity of Illinois,Chicago
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisUniversity of Illinois,Chicago
 
10. Getting Spatial
10. Getting Spatial10. Getting Spatial
10. Getting SpatialFAO
 
R getting spatial
R getting spatialR getting spatial
R getting spatialFAO
 
Regression and Classification with R
Regression and Classification with RRegression and Classification with R
Regression and Classification with RYanchang Zhao
 
Data manipulation and visualization in r 20190711 myanmarucsy
Data manipulation and visualization in r 20190711 myanmarucsyData manipulation and visualization in r 20190711 myanmarucsy
Data manipulation and visualization in r 20190711 myanmarucsySmartHinJ
 
Time Series Analysis and Mining with R
Time Series Analysis and Mining with RTime Series Analysis and Mining with R
Time Series Analysis and Mining with RYanchang Zhao
 
Introduction to R
Introduction to RIntroduction to R
Introduction to RStacy Irwin
 
R Spatial Analysis using SP
R Spatial Analysis using SPR Spatial Analysis using SP
R Spatial Analysis using SPtjagger
 
Direct split-radix algorithm for fast computation of type-II discrete Hartley...
Direct split-radix algorithm for fast computation of type-II discrete Hartley...Direct split-radix algorithm for fast computation of type-II discrete Hartley...
Direct split-radix algorithm for fast computation of type-II discrete Hartley...TELKOMNIKA JOURNAL
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#bleis tift
 
Writing Readable Code with Pipes
Writing Readable Code with PipesWriting Readable Code with Pipes
Writing Readable Code with PipesRsquared Academy
 
M12 random forest-part01
M12 random forest-part01M12 random forest-part01
M12 random forest-part01Raman Kannan
 
Morel, a data-parallel programming language
Morel, a data-parallel programming languageMorel, a data-parallel programming language
Morel, a data-parallel programming languageJulian Hyde
 
Declare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingDeclare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingEelco Visser
 
Data manipulation with dplyr
Data manipulation with dplyrData manipulation with dplyr
Data manipulation with dplyrRomain Francois
 

Similar to Eurostat cheatsheet (20)

Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency Analysis
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency Analysis
 
10. Getting Spatial
10. Getting Spatial10. Getting Spatial
10. Getting Spatial
 
10. R getting spatial
10.  R getting spatial10.  R getting spatial
10. R getting spatial
 
R programming language
R programming languageR programming language
R programming language
 
R getting spatial
R getting spatialR getting spatial
R getting spatial
 
Regression and Classification with R
Regression and Classification with RRegression and Classification with R
Regression and Classification with R
 
Data manipulation and visualization in r 20190711 myanmarucsy
Data manipulation and visualization in r 20190711 myanmarucsyData manipulation and visualization in r 20190711 myanmarucsy
Data manipulation and visualization in r 20190711 myanmarucsy
 
Time Series Analysis and Mining with R
Time Series Analysis and Mining with RTime Series Analysis and Mining with R
Time Series Analysis and Mining with R
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
R Spatial Analysis using SP
R Spatial Analysis using SPR Spatial Analysis using SP
R Spatial Analysis using SP
 
Direct split-radix algorithm for fast computation of type-II discrete Hartley...
Direct split-radix algorithm for fast computation of type-II discrete Hartley...Direct split-radix algorithm for fast computation of type-II discrete Hartley...
Direct split-radix algorithm for fast computation of type-II discrete Hartley...
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#
 
Writing Readable Code with Pipes
Writing Readable Code with PipesWriting Readable Code with Pipes
Writing Readable Code with Pipes
 
Advanced C - Part 3
Advanced C - Part 3Advanced C - Part 3
Advanced C - Part 3
 
M12 random forest-part01
M12 random forest-part01M12 random forest-part01
M12 random forest-part01
 
Morel, a data-parallel programming language
Morel, a data-parallel programming languageMorel, a data-parallel programming language
Morel, a data-parallel programming language
 
Declare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingDeclare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term Rewriting
 
Python Session - 3
Python Session - 3Python Session - 3
Python Session - 3
 
Data manipulation with dplyr
Data manipulation with dplyrData manipulation with dplyr
Data manipulation with dplyr
 

More from Dieudonne Nahigombeye (11)

Sparklyr
SparklyrSparklyr
Sparklyr
 
Rstudio ide-cheatsheet
Rstudio ide-cheatsheetRstudio ide-cheatsheet
Rstudio ide-cheatsheet
 
Rmarkdown cheatsheet-2.0
Rmarkdown cheatsheet-2.0Rmarkdown cheatsheet-2.0
Rmarkdown cheatsheet-2.0
 
Reg ex cheatsheet
Reg ex cheatsheetReg ex cheatsheet
Reg ex cheatsheet
 
How big-is-your-graph
How big-is-your-graphHow big-is-your-graph
How big-is-your-graph
 
Ggplot2 cheatsheet-2.1
Ggplot2 cheatsheet-2.1Ggplot2 cheatsheet-2.1
Ggplot2 cheatsheet-2.1
 
Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Data transformation-cheatsheet
Data transformation-cheatsheetData transformation-cheatsheet
Data transformation-cheatsheet
 
Data import-cheatsheet
Data import-cheatsheetData import-cheatsheet
Data import-cheatsheet
 
Base r
Base rBase r
Base r
 
Advanced r
Advanced rAdvanced r
Advanced r
 

Recently uploaded

Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 

Recently uploaded (20)

Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 

Eurostat cheatsheet

  • 1. Group Cases Search and download www www eurostat and plots . . wwwwww wwwwww www ww wwwww R tools to access open data from Eurostat database The eurostat package Data in the Eurostat database is stored in tables. Each table has an identifier, a short table_code, and a description (e.g. tsdtr420 - People killed in road accidents). Key eurostat functions allow to find the table_code, download the eurostat table and polish labels in the table. library("eurostat") query <- search_eurostat("road", type = "table") query[1:3,1:2] ## title code ## 1 Goods transport by road ttr00005 ## 2 People killed in road accidents tsdtr420 ## 3 Enterprises with broadband access tin00090 The get_eurostat() function returns tibbles in the long format. Packages dplyr and tidyr are well suited to transform these objects. The ggplot2 package is well suited to plot these objects. t1 <- get_eurostat("tsdtr420", filters = list(geo = c("UK", "FR", "PL", "ES", "PT"))) library("ggplot2") ggplot(t1, aes(x = time, y = values, color = geo, group = geo, shape = geo)) + geom_point(size = 2) + geom_line() + theme_bw() + labs(title="Road accidents", x = "Year", y = "Victims") eurostat and maps This onepager presents the eurostat package Leo Lahti, Janne Huovari, Markus Kainu, Przemyslaw Biecek 2014-2017 package version 2.2.43 URL: https://github.com/rOpenGov/eurostat Find the table code Thesearch_eurostat(pattern,...)functionscansthedirectoryofEuro- stat tables and returns codes and descriptions of tables that match pattern. Download the table The get_eurostat(id, time_format = "date", filters = "none", type = "code", cache = TRUE, ...) function downloads the requested table from the Eurostatbulkdownloadfacility or from TheEurostatWebServi- ces JSON API (if filters are defined). Downloaded data is cached (if cache=TRUE). Additional arguments define how to read the time column (time_format) and if table dimensions shall be kept as codes or converted to labels (type). dat <- get_eurostat(id="tsdtr420", time_format="num") head(dat) ## unit sex geo time values ## 1 NR T AT 1999 1079 ## 2 NR T BE 1999 1397 ## 3 NR T CZ 1999 1455 ## 4 NR T DK 1999 514 ## 5 NR T EL 1999 2116 ## 6 NR T ES 1999 5738 Add labels The label_eurostat(x, lang = "en", ...) gets definitions for Eurostat codes and replace them with labels in given language ("en", "fr" or "de"). dat <- label_eurostat(dat) head(dat) ## unit sex geo time values ## 1 Number Total Austria 1999 1079 ## 2 Number Total Belgium 1999 1397 ## 3 Number Total Czech Republic 1999 1455 ## 4 Number Total Denmark 1999 514 ## 5 Number Total Greece 1999 2116 ## 6 Number Total Spain 1999 5738 library("dplyr") t2 <- t1 %>% filter(time == "2014-01-01") ggplot(t2, aes(geo, values, fill=geo)) + geom_bar(stat = "identity") + theme_bw() + theme(legend.position = "none")+ labs(title="Road accidents in 2014", x="", y="Victims") There are three function to work with geospatial data from GISCO. The get_eurostat_geospatial() returns preprocessed spatial data as sp-ob- jects or as data frames. The merge_eurostat_geospatial() both down- loads and merges the geospatial data with a preloaded tabular data. The cut_to_classes() is a wrapper for cut() - function and is used for categori- zing data for maps with tidy labels. Fetch and process data library("eurostat") library("dplyr") fertility <- get_eurostat("demo_r_frate3") %>% filter(time == "2014-01-01") %>% mutate(cat = cut_to_classes(values, n=7, decimals=1)) mapdata <- merge_eurostat_geodata(fertility, resolution = "20") head(select(mapdata,geo,values,cat,long,lat,order,id)) ## geo values cat long lat order id ## 1 AT124 1.39 1.3 ~< 1.5 15.54245 48.90770 214 10 ## 2 AT124 1.39 1.3 ~< 1.5 15.75363 48.85218 215 10 ## 3 AT124 1.39 1.3 ~< 1.5 15.88763 48.78511 216 10 ## 4 AT124 1.39 1.3 ~< 1.5 15.81535 48.69270 217 10 ## 5 AT124 1.39 1.3 ~< 1.5 15.94094 48.67173 218 10 ## 6 AT124 1.39 1.3 ~< 1.5 15.90833 48.59815 219 10 40 50 60 −10 0 10 20 30 40 long lat 0.9 ~< 1.3 1.3 ~< 1.5 1.5 ~< 1.7 1.7 ~< 1.9 1.9 ~< 2.3 2.3 ~< 3.1 3.1 ~< 4.5 library("ggplot2") ggplot(mapdata, aes(x = long, y = lat, group = group))+ geom_polygon(aes(fill=cat), color="grey", size = .1)+ scale_fill_brewer(palette = "RdYlBu") + labs(title="Fertility rate, by NUTS-3 regions, 2014", subtitle="Avg. number of live births per woman", fill="Total fertility rate(%)") + theme_light()+ coord_map(xlim=c(-12,44), ylim=c(35,67)) Draw a cartogram The object returned by merge_eurostat_geospatial() are ready to be plotted with ggplot2 package. The coord_map() function is useful to set the projection while labs() adds annotations o the plot. ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 2000 4000 6000 8000 2000 2005 2010 2015 Year Victims geo ● ES FR PL PT UK Road accidents 0 1000 2000 3000 ES FR PL PT UK Victims Road accidents in 2014 40 50 60 −10 0 10 20 30 40 long lat Total fertility rate(%) 0.9 ~< 1.3 1.3 ~< 1.5 1.5 ~< 1.7 1.7 ~< 1.9 1.9 ~< 2.3 2.3 ~< 3.1 3.1 ~< 4.5 Avg. number of live births per woman Fertility rate, by NUTS−3 regions, 2014 CC BY Przemyslaw Biecek https://creativecommons.org/licenses/by/4.0/