-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1_numeral_construction.qmd
109 lines (92 loc) · 2.91 KB
/
1_numeral_construction.qmd
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
97
98
99
100
101
102
103
104
105
106
107
---
title: Numeral construction
author: Chiara Naccarato, Svetlana Zemicheva
date: 'Last update: `r lubridate::make_datetime(year = 2024, month = 12, day = 1)`'
output:
html_document:
number_sections: true
anchor_sections: true
pandoc_args: --shift-heading-level-by=-1
---
```{r, include=FALSE}
library(tidyverse)
readxl::read_xlsx('data/data.xlsx') |>
filter(feature_id == 1) ->
db
```
Here will be short text
##
::: {.panel-tabset}
### Non-fully standard speakers
```{r}
library(waffle)
db |>
mutate(standardness = if_else(non_standard == 0, 'fully standard speakers', 'non-fully standard speakers')) |>
count(corpus, standardness) |>
ggplot(aes(fill = standardness, values = n))+
geom_waffle(colour = 'white', size = 0.5)+
facet_wrap(~corpus, ncol = 2) +
scale_fill_manual(name = NULL, values = c('#c68958', '#9AC0CD')) +
theme_enhance_waffle()+
theme_void()+
theme(legend.position = 'top', text = element_text(size = 15))
```
### Map
```{r}
db |>
mutate(standardness = if_else(non_standard == 0, 'fully standard speakers', 'non-fully standard speakers')) |>
count(corpus, standardness, latitude, longitude, url) |>
mutate(url = str_glue('<a href={url}>{corpus}</a>')) |>
pivot_wider(names_from = standardness, values_from = n) ->
for_map
if(!('fully standard speakers' %in% colnames(for_map))) {
for_map |>
mutate(`fully standard speakers` = 0) ->
for_map
}
library(leaflet)
library(leaflet.minicharts)
leaflet() |>
addTiles() |>
addMinicharts(lng = for_map$longitude,
lat = for_map$latitude,
type = 'pie',
chartdata = for_map[, c('fully standard speakers', 'non-fully standard speakers')],
showLabels = TRUE,
popup = leaflet.minicharts::popupArgs(html = for_map$url))
```
### Variation
```{r}
library(tidytext)
db |>
filter(non_standard > 0) |>
mutate(total = non_standard + standard,
ratio = non_standard/total,
speaker = reorder_within(speaker, by = ratio, within = corpus)) |>
ggplot(aes(ratio, speaker))+
geom_point()+
facet_wrap(~corpus, scales = 'free_y', ncol = 2)+
scale_y_reordered()+
scale_x_continuous(labels = scales::percent)+
labs(x = NULL, y = NULL)+
theme_minimal()+
theme(axis.text.y = element_blank(), text = element_text(size = 15))
```
### Raw data
```{r}
db |>
select(corpus, speaker, non_standard, standard) |>
DT::datatable(class = 'cell-border stripe',
rownames = FALSE,
filter = 'top',
extensions = 'Buttons',
options = list(pageLength = 42,
autoWidth = TRUE,
info = FALSE,
dom = 'fBltp',
buttons = list(list(extend = 'collection',
buttons = c('csv', 'excel', 'pdf'),
text = '<i class="fas fa-download"></i>')),
paginate = TRUE))
```
:::