1
1
---
2
2
title : " General statistical overviews of FILTER data"
3
3
date : " `r Sys.Date()`"
4
- output :
4
+ output :
5
5
html_notebook :
6
6
code_folding : hide
7
7
toc : yes
@@ -11,110 +11,111 @@ output:
11
11
---
12
12
13
13
``` {r setup, include=FALSE}
14
- knitr::opts_chunk$set(message= FALSE,dpi= 300,fig.retina=2, fig.width= 8)
14
+ knitr::opts_chunk$set(message = FALSE, dpi = 300, fig.retina = 2, fig.width = 8)
15
15
source(here::here("src/common_basis.R"))
16
16
tmap_mode("plot")
17
17
```
18
18
19
19
``` {r}
20
- polygons %>%
21
- filter(map_id== 1) %>%
20
+ polygons %>%
21
+ filter(map_id == 1) %>%
22
22
left_join(p_pl %>% count(pl_id) %>% collect()) %>%
23
- replace_na(list(n= 0)) %>%
23
+ replace_na(list(n = 0)) %>%
24
24
group_by(pol_id, geometry) %>%
25
- summarise(n= sum(n)) %>%
25
+ summarise(n = sum(n)) %>%
26
26
tm_shape() +
27
- tm_polygons(col='n' , id=' name' , style=' fisher' , palette=' plasma' ) +
28
- tm_layout(main.title= "Exp-1")
27
+ tm_polygons(col = "n" , id = " name" , style = " fisher" , palette = " plasma" ) +
28
+ tm_layout(main.title = "Exp-1")
29
29
```
30
30
31
31
``` {r}
32
- polygons %>%
33
- filter(map_id== 0) %>%
32
+ polygons %>%
33
+ filter(map_id == 0) %>%
34
34
left_join(p_pl %>% count(pl_id) %>% collect()) %>%
35
35
group_by(pol_id, geometry) %>%
36
- summarise(n= sum(n)) %>%
36
+ summarise(n = sum(n)) %>%
37
37
tm_shape() +
38
- tm_polygons(col='n' , id=' name' , style=' fisher' , palette=' plasma' ) +
39
- tm_layout(main.title= "Exp-1")
38
+ tm_polygons(col = "n" , id = " name" , style = " fisher" , palette = " plasma" ) +
39
+ tm_layout(main.title = "Exp-1")
40
40
```
41
41
42
42
``` {r}
43
- polygons %>%
44
- filter(map_id== 0) %>%
43
+ polygons %>%
44
+ filter(map_id == 0) %>%
45
45
left_join(p_pl %>% count(pl_id) %>% collect()) %>%
46
46
group_by(pol_id, geometry) %>%
47
- summarise(n= sum(n)) %>%
47
+ summarise(n = sum(n)) %>%
48
48
tm_shape() +
49
49
tm_polygons() +
50
- tm_bubbles(size = "n", col= "n") +
51
- tm_layout(main.title= "Exp-1")
50
+ tm_bubbles(size = "n", col = "n") +
51
+ tm_layout(main.title = "Exp-1")
52
52
```
53
53
``` {r}
54
- polygons %>%
55
- filter(map_id== 1) %>%
54
+ polygons %>%
55
+ filter(map_id == 1) %>%
56
56
left_join(p_pl %>% count(pl_id) %>% collect()) %>%
57
- replace_na(list(n= 0)) %>%
57
+ replace_na(list(n = 0)) %>%
58
58
group_by(pol_id, geometry) %>%
59
- summarise(n= sum(n)) %>%
60
- tm_shape(point.per= "largest") +
59
+ summarise(n = sum(n)) %>%
60
+ tm_shape(point.per = "largest") +
61
61
tm_polygons() +
62
- tm_bubbles(size = "n", col= "n") +
63
- tm_layout(main.title= "Exp-1")
62
+ tm_bubbles(size = "n", col = "n") +
63
+ tm_layout(main.title = "Exp-1")
64
64
```
65
65
66
66
``` {r}
67
- d <- polygons %>%
68
- filter(map_id== 0) %>%
67
+ d <- polygons %>%
68
+ filter(map_id == 0) %>%
69
69
left_join(p_pl %>% inner_join(poems) %>% count(collection, pl_id) %>% collect()) %>%
70
- replace_na(list(n= 0)) %>%
70
+ replace_na(list(n = 0)) %>%
71
71
group_by(collection, pol_id, geometry) %>%
72
- summarise(n= sum(n)) %>%
72
+ summarise(n = sum(n)) %>%
73
73
group_by(pol_id) %>%
74
- mutate(tn= sum(n)) %>%
74
+ mutate(tn = sum(n)) %>%
75
75
ungroup() %>%
76
- mutate(pol_id= str_c("p", pol_id), collection= as_factor(collection))
76
+ mutate(pol_id = str_c("p", pol_id), collection = as_factor(collection))
77
77
78
78
plot_cols <- coloropt_pal()(4)
79
79
80
- grps <- d %>%
81
- # filter(!is.na(n)) %>%
82
- complete(nesting(pol_id,tn,geometry),collection,fill=list(n=0)) %>%
83
- group_by(pol_id)
84
- grobs <- grps %>%
85
- group_map(~ggplotGrob(ggplot(.x, aes(x="", y=n, fill=collection)) +
86
- geom_col(width=1) +
87
- scale_y_continuous(expand=c(0,0)) +
88
- scale_fill_manual(values=plot_cols) +
89
- theme_ps(plot.axes = FALSE))
90
- ) %>%
80
+ grps <- d %>%
81
+ # filter(!is.na(n)) %>%
82
+ complete(nesting(pol_id, tn, geometry), collection, fill = list(n = 0)) %>%
83
+ group_by(pol_id)
84
+ grobs <- grps %>%
85
+ group_map(~ ggplotGrob(ggplot(.x, aes(x = "", y = n, fill = collection)) +
86
+ geom_col(width = 1) +
87
+ scale_y_continuous(expand = c(0, 0)) +
88
+ scale_fill_manual(values = plot_cols) +
89
+ theme_ps(plot.axes = FALSE))) %>%
91
90
set_names(group_keys(grps) %>% pull())
92
91
```
93
92
94
93
95
94
``` {r,fig.width=10,fig.height=14}
96
95
d %>%
97
- distinct(pol_id,geometry,tn) %>%
98
- tm_shape(point.per= "largest") +
96
+ distinct(pol_id, geometry, tn) %>%
97
+ tm_shape(point.per = "largest") +
99
98
tm_polygons() +
100
- tm_symbols(shape="pol_id",
101
- shapes=grobs,
102
- size="tn",
103
- legend.shape.show = FALSE,
104
- legend.size.is.portrait = TRUE,
105
- shapes.legend = 22) +
106
- tm_add_legend(type="fill",
107
- col=plot_cols,
108
- labels=c("erab", "jr", "literary", "skvr"),
109
- title="Collection")
110
-
99
+ tm_symbols(
100
+ shape = "pol_id",
101
+ shapes = grobs,
102
+ size = "tn",
103
+ legend.shape.show = FALSE,
104
+ legend.size.is.portrait = TRUE,
105
+ shapes.legend = 22
106
+ ) +
107
+ tm_add_legend(
108
+ type = "fill",
109
+ col = plot_cols,
110
+ labels = c("erab", "jr", "literary", "skvr"),
111
+ title = "Collection"
112
+ )
111
113
```
112
114
113
115
``` {r}
114
116
d %>%
115
117
tm_shape() +
116
118
tm_polygons() +
117
- tm_bubbles(size= "n") +
118
- tm_facets(by= "collection",ncol= 4)
119
+ tm_bubbles(size = "n") +
120
+ tm_facets(by = "collection", ncol = 4)
119
121
```
120
-
0 commit comments