-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples1.R
65 lines (51 loc) · 2.11 KB
/
examples1.R
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
library("eurostat")
library("ggplot2")
library("tidyverse")
library("bpa")
library("here")
# Liste aller Datensätze
# toc <- get_eurostat_toc()
#
# Geburtenrate
#
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")
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, ny 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))
#
# Bevölkerung
#
population <- get_eurostat("tps00010")
# der Datnsatz enth?lt auch Gruppierungen und L?nder, die nicht in der EU sind
# nur EU L?nder sollen ausgew?hlt werden
sel <- eu_countries %>% select(code)
population_sel <- population %>% filter(geo %in% c(t(sel)))
# rename, damit join funktioniert
country <- eu_countries %>% rename(geo = code, geo_name = name)
population_gg <- population_sel %>% left_join(country)
# Darstellung pro Land (28)
ggplot(population_gg, aes(x = time, y = values, fill = indic_de)) +
geom_bar(stat = "identity", position = "stack") +
facet_wrap(~ geo_name)
# Darstellung pro Jahr (12; 2005-2016)
ggplot(population_gg, aes(x = geo_name, y = values, fill = indic_de)) +
geom_bar(stat = "identity", position = "stack") +
facet_wrap(~ time) +
coord_flip()
#
# Urban: große Städte
#
# urban_cities %>% basic_pattern_analysis() %>% head(10)
# bpa(urban_cities, unique_only = TRUE)
urban_cities <- get_eurostat("urb_cpop1")
# pop_structure <- get_eurostat("urb_cpopstr")
cities <- read_csv("cities.csv") %>% select(Label, Notation) %>% rename(cities = Notation, city_label = Label)
indic <- read_csv("indic_ur.csv") %>% select(Label, Notation) %>% rename(indic_ur = Notation, indic_label = Label) %>% filter(grepl("^DE", indic_ur))
urban_cities <- urban_cities %>% left_join(cities)
used_indic = urban_cities %>% distinct(indic_ur) %>% left_join(indic)