Packages
# install.packages("pacman") #jau izdarīts, vairs nav jāatkārto
# install.packages('BiocManager')
# in ubuntu check if libgdal-dev is installed for the sf package
pacman::p_load(tidyverse,
janitor,
MatchIt,
table1,
tableone,
gtsummary,
survival,
ggpubr,
RColorBrewer,
ggmap,
geojsonR,
leaflet,
rgdal,
here,
sf, # would require libgdal-dev install in Ubuntu
dataReporter, # for the codebook
viridis) # paleta de colores
theme_set(theme_minimal())
Load the dataset
df <- read_csv(here("data", "01_df.csv"))
df_sin <- read_csv(here("data", "02_df_sin.csv"))
EDA
head(df)
?head #lai zinātu, kam šī komanda domāta, labajā pusē parādās apraksts
dim(df)
## [1] 17446 21
dim(df_sin)
## [1] 14800 23
glimpse(df)
## Rows: 17,446
## Columns: 21
## $ count <dbl> 1, 1, 1, 1,…
## $ timestamp <chr> "14/01/2020…
## $ datu_ievades_operators <dbl> 8, 2, 2, 12…
## $ ieraksta_id <chr> "6_0607", "…
## $ day <dbl> 11, 10, 10,…
## $ months <dbl> 4, 1, 1, 1,…
## $ year <dbl> 2011, 2005,…
## $ narkozes_datums <chr> "4/11/2011"…
## $ narkozes_apmeklejums <chr> "Primary", …
## $ pacienta_personas_kods <chr> "f0c332c2b8…
## $ vecums <dbl> 13, 6, 10, …
## $ pacienta_dzimums <chr> "Female", "…
## $ pacienta_dzivesvieta <chr> "Rīga", "Rī…
## $ pacienta_dzivesvietas_pilsetas_rajona_vai_novada_nosaukums <chr> "Rīga", "Rī…
## $ kopa_estraheto_un_arsteto_zobu_skaits <dbl> 7, 2, 9, 9,…
## $ plombeto_zobu_skaits <dbl> 5, 2, 8, 9,…
## $ ekstraheto_zobu_skaits <dbl> 2, 0, 1, 0,…
## $ invaliditate <chr> "No", "No",…
## $ apmaksas_veids <chr> "Public", "…
## $ age_groups <chr> "6-17", "6-…
## $ year_group <chr> "2010-2014"…
glimpse(df_sin)
## Rows: 14,800
## Columns: 23
## $ count <dbl> 1, 1, 1, 1,…
## $ timestamp <chr> "14/01/2020…
## $ datu_ievades_operators <dbl> 8, 2, 2, 12…
## $ ieraksta_id <chr> "6_0607", "…
## $ day <dbl> 11, 10, 10,…
## $ months <dbl> 4, 1, 1, 1,…
## $ year <dbl> 2011, 2005,…
## $ narkozes_datums <chr> "4/11/2011"…
## $ narkozes_apmeklejums <chr> "Primary", …
## $ pacienta_personas_kods <chr> "f0c332c2b8…
## $ pacienta_dzimsanas_datums <chr> "10/18/1997…
## $ vecums <dbl> 13, 6, 10, …
## $ pacienta_dzimums <chr> "Female", "…
## $ pacienta_dzivesvieta <chr> "Rīga", "Rī…
## $ pacienta_dzivesvietas_pilsetas_rajona_vai_novada_nosaukums <chr> "Rīga", "Rī…
## $ kopa_estraheto_un_arsteto_zobu_skaits <dbl> 7, 2, 9, 9,…
## $ plombeto_zobu_skaits <dbl> 5, 2, 8, 9,…
## $ ekstraheto_zobu_skaits <dbl> 2, 0, 1, 0,…
## $ invaliditate <chr> "Nav", "Nav…
## $ apmaksas_veids <chr> "Public", "…
## $ arstesanas_datums <chr> "4/11/2011"…
## $ age_groups <chr> "6-17", "6-…
## $ year_group <chr> "2010-2014"…
class(df$narkozes_datums)
## [1] "character"
df %>%
distinct(pacienta_personas_kods)
df %>%
distinct(pacienta_personas_kods, .keep_all = T) %>%
tabyl(pacienta_dzimums)
df_sin %>%
distinct(pacienta_personas_kods)
df_sin %>%
distinct(pacienta_personas_kods, .keep_all = T) %>%
tabyl(pacienta_dzimums)
TABLE and Supplement 1
df %>%
select(invaliditate, pacienta_dzimums , vecums , age_groups , narkozes_apmeklejums, apmaksas_veids, year ) %>%
gtsummary::tbl_summary(by = year) %>%
bold_labels() %>%
as_gt() %>%
gt::gtsave(here("tables", "table1.html"))
# as_hux_table(here("tables", "table1.docx"),
# include = everything())
# as_flex_table() %>%
# flextable::save_as_docx(path = here("tables", "table1.docx"))
table1::table1(
~ invaliditate + pacienta_dzimums + vecums + age_groups + narkozes_apmeklejums + apmaksas_veids |
year,
data = df
)
|
2005 (N=395) |
2006 (N=644) |
2007 (N=682) |
2008 (N=753) |
2009 (N=798) |
2010 (N=912) |
2011 (N=1001) |
2012 (N=1153) |
2013 (N=1264) |
2014 (N=1158) |
2015 (N=1305) |
2016 (N=1323) |
2017 (N=1485) |
2018 (N=1338) |
2019 (N=1608) |
2020 (N=1627) |
Overall (N=17446) |
invaliditate |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
No |
347 (87.8%) |
594 (92.2%) |
631 (92.5%) |
663 (88.0%) |
685 (85.8%) |
788 (86.4%) |
882 (88.1%) |
998 (86.6%) |
1098 (86.9%) |
975 (84.2%) |
1080 (82.8%) |
1105 (83.5%) |
1261 (84.9%) |
1104 (82.5%) |
1251 (77.8%) |
1338 (82.2%) |
14800 (84.8%) |
Yes |
48 (12.2%) |
50 (7.8%) |
51 (7.5%) |
90 (12.0%) |
113 (14.2%) |
124 (13.6%) |
119 (11.9%) |
155 (13.4%) |
166 (13.1%) |
183 (15.8%) |
225 (17.2%) |
218 (16.5%) |
224 (15.1%) |
234 (17.5%) |
357 (22.2%) |
289 (17.8%) |
2646 (15.2%) |
pacienta_dzimums |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Female |
175 (44.3%) |
263 (40.8%) |
299 (43.8%) |
336 (44.6%) |
347 (43.5%) |
393 (43.1%) |
444 (44.4%) |
505 (43.8%) |
542 (42.9%) |
465 (40.2%) |
539 (41.3%) |
571 (43.2%) |
639 (43.0%) |
558 (41.7%) |
663 (41.2%) |
683 (42.0%) |
7422 (42.5%) |
Male |
220 (55.7%) |
381 (59.2%) |
383 (56.2%) |
417 (55.4%) |
451 (56.5%) |
519 (56.9%) |
557 (55.6%) |
648 (56.2%) |
722 (57.1%) |
693 (59.8%) |
766 (58.7%) |
752 (56.8%) |
846 (57.0%) |
780 (58.3%) |
945 (58.8%) |
944 (58.0%) |
10024 (57.5%) |
vecums |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mean (SD) |
4.04 (2.97) |
3.95 (2.77) |
3.87 (2.74) |
4.21 (3.22) |
4.47 (3.27) |
4.63 (3.34) |
4.49 (2.91) |
4.89 (3.20) |
4.83 (3.07) |
4.94 (2.91) |
4.92 (3.04) |
4.95 (2.90) |
5.02 (3.06) |
5.28 (3.13) |
5.71 (3.43) |
5.48 (3.16) |
4.89 (3.14) |
Median [Min, Max] |
3.00 [1.00, 17.0] |
3.00 [1.00, 17.0] |
3.00 [1.00, 17.0] |
3.00 [1.00, 17.0] |
3.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
5.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
age_groups |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1-3 |
231 (58.5%) |
388 (60.2%) |
416 (61.0%) |
432 (57.4%) |
419 (52.5%) |
435 (47.7%) |
449 (44.9%) |
435 (37.7%) |
473 (37.4%) |
392 (33.9%) |
482 (36.9%) |
451 (34.1%) |
506 (34.1%) |
385 (28.8%) |
407 (25.3%) |
396 (24.3%) |
6697 (38.4%) |
4-5 |
106 (26.8%) |
160 (24.8%) |
174 (25.5%) |
200 (26.6%) |
221 (27.7%) |
298 (32.7%) |
362 (36.2%) |
451 (39.1%) |
491 (38.8%) |
469 (40.5%) |
481 (36.9%) |
514 (38.9%) |
588 (39.6%) |
544 (40.7%) |
620 (38.6%) |
700 (43.0%) |
6379 (36.6%) |
6-17 |
58 (14.7%) |
96 (14.9%) |
92 (13.5%) |
121 (16.1%) |
158 (19.8%) |
179 (19.6%) |
190 (19.0%) |
267 (23.2%) |
300 (23.7%) |
297 (25.6%) |
342 (26.2%) |
358 (27.1%) |
391 (26.3%) |
409 (30.6%) |
581 (36.1%) |
531 (32.6%) |
4370 (25.0%) |
narkozes_apmeklejums |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Primary |
358 (90.6%) |
574 (89.1%) |
612 (89.7%) |
675 (89.6%) |
692 (86.7%) |
799 (87.6%) |
900 (89.9%) |
1041 (90.3%) |
1144 (90.5%) |
1028 (88.8%) |
1154 (88.4%) |
1152 (87.1%) |
1283 (86.4%) |
1120 (83.7%) |
1246 (77.5%) |
1265 (77.8%) |
15043 (86.2%) |
Repeated |
37 (9.4%) |
70 (10.9%) |
70 (10.3%) |
78 (10.4%) |
106 (13.3%) |
113 (12.4%) |
101 (10.1%) |
112 (9.7%) |
120 (9.5%) |
130 (11.2%) |
151 (11.6%) |
171 (12.9%) |
202 (13.6%) |
218 (16.3%) |
362 (22.5%) |
362 (22.2%) |
2403 (13.8%) |
apmaksas_veids |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Public |
395 (100%) |
644 (100%) |
682 (100%) |
719 (95.5%) |
580 (72.7%) |
629 (69.0%) |
630 (62.9%) |
628 (54.5%) |
589 (46.6%) |
693 (59.8%) |
623 (47.7%) |
604 (45.7%) |
677 (45.6%) |
552 (41.3%) |
887 (55.2%) |
1089 (66.9%) |
10621 (60.9%) |
Privat |
0 (0%) |
0 (0%) |
0 (0%) |
34 (4.5%) |
218 (27.3%) |
283 (31.0%) |
371 (37.1%) |
525 (45.5%) |
675 (53.4%) |
465 (40.2%) |
682 (52.3%) |
719 (54.3%) |
808 (54.4%) |
786 (58.7%) |
721 (44.8%) |
538 (33.1%) |
6825 (39.1%) |
Other design of table
# pacman::p_load(gtsummary)
# df %>%
# select(invaliditate, pacienta_dzimums , vecums , age_groups , narkozes_apmeklejums , apmaksas_veids, year) %>%
# gtsummary::tbl_summary(by = year) %>%
# gtsummary::bold_labels()
Grouping years
df %>%
select(invaliditate , pacienta_dzimums , vecums , age_groups , narkozes_apmeklejums , apmaksas_veids , year_group ) %>%
gtsummary::tbl_summary(by = year_group) %>%
bold_labels() %>%
as_gt() %>%
gt::gtsave(here("tables", "table1_1.html"))
# as_hux_table(here("tables", "table1.docx"),
# include = everything())
# as_flex_table() %>%
# flextable::save_as_docx(path = here("tables", "table1.docx"))
# df %>%
# select(invaliditate, pacienta_dzimums , vecums , age_groups , narkozes_apmeklejums, apmaksas_veids, year ) %>%
# gtsummary::tbl_summary(by = year)
table1::table1(
~ invaliditate + pacienta_dzimums + vecums + age_groups + narkozes_apmeklejums + apmaksas_veids |
year_group,
data = df
)
|
2005-2009 (N=3272) |
2010-2014 (N=5488) |
2015-2019 (N=7059) |
2020 (N=1627) |
Overall (N=17446) |
invaliditate |
|
|
|
|
|
No |
2920 (89.2%) |
4741 (86.4%) |
5801 (82.2%) |
1338 (82.2%) |
14800 (84.8%) |
Yes |
352 (10.8%) |
747 (13.6%) |
1258 (17.8%) |
289 (17.8%) |
2646 (15.2%) |
pacienta_dzimums |
|
|
|
|
|
Female |
1420 (43.4%) |
2349 (42.8%) |
2970 (42.1%) |
683 (42.0%) |
7422 (42.5%) |
Male |
1852 (56.6%) |
3139 (57.2%) |
4089 (57.9%) |
944 (58.0%) |
10024 (57.5%) |
vecums |
|
|
|
|
|
Mean (SD) |
4.13 (3.03) |
4.77 (3.09) |
5.20 (3.15) |
5.48 (3.16) |
4.89 (3.14) |
Median [Min, Max] |
3.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
age_groups |
|
|
|
|
|
1-3 |
1886 (57.6%) |
2184 (39.8%) |
2231 (31.6%) |
396 (24.3%) |
6697 (38.4%) |
4-5 |
861 (26.3%) |
2071 (37.7%) |
2747 (38.9%) |
700 (43.0%) |
6379 (36.6%) |
6-17 |
525 (16.0%) |
1233 (22.5%) |
2081 (29.5%) |
531 (32.6%) |
4370 (25.0%) |
narkozes_apmeklejums |
|
|
|
|
|
Primary |
2911 (89.0%) |
4912 (89.5%) |
5955 (84.4%) |
1265 (77.8%) |
15043 (86.2%) |
Repeated |
361 (11.0%) |
576 (10.5%) |
1104 (15.6%) |
362 (22.2%) |
2403 (13.8%) |
apmaksas_veids |
|
|
|
|
|
Privat |
252 (7.7%) |
2319 (42.3%) |
3716 (52.6%) |
538 (33.1%) |
6825 (39.1%) |
Public |
3020 (92.3%) |
3169 (57.7%) |
3343 (47.4%) |
1089 (66.9%) |
10621 (60.9%) |
TABLE and Supplement 2
df %>%
select(pacienta_dzimums , vecums , age_groups , narkozes_apmeklejums , apmaksas_veids , year ) %>%
gtsummary::tbl_summary(by = year) %>%
bold_labels() %>%
as_gt() %>%
gt::gtsave(here("tables", "table1_2.html"))
table1::table1(
~ pacienta_dzimums + vecums + age_groups + narkozes_apmeklejums + apmaksas_veids |
year,
data = df_sin
)
|
2005 (N=347) |
2006 (N=594) |
2007 (N=631) |
2008 (N=663) |
2009 (N=685) |
2010 (N=788) |
2011 (N=882) |
2012 (N=998) |
2013 (N=1098) |
2014 (N=975) |
2015 (N=1080) |
2016 (N=1105) |
2017 (N=1261) |
2018 (N=1104) |
2019 (N=1251) |
2020 (N=1338) |
Overall (N=14800) |
pacienta_dzimums |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Female |
155 (44.7%) |
240 (40.4%) |
275 (43.6%) |
308 (46.5%) |
306 (44.7%) |
347 (44.0%) |
397 (45.0%) |
444 (44.5%) |
482 (43.9%) |
399 (40.9%) |
461 (42.7%) |
490 (44.3%) |
553 (43.9%) |
471 (42.7%) |
529 (42.3%) |
571 (42.7%) |
6428 (43.4%) |
Male |
192 (55.3%) |
354 (59.6%) |
356 (56.4%) |
355 (53.5%) |
379 (55.3%) |
441 (56.0%) |
485 (55.0%) |
554 (55.5%) |
616 (56.1%) |
576 (59.1%) |
619 (57.3%) |
615 (55.7%) |
708 (56.1%) |
633 (57.3%) |
722 (57.7%) |
767 (57.3%) |
8372 (56.6%) |
vecums |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mean (SD) |
3.41 (1.98) |
3.57 (2.24) |
3.52 (2.19) |
3.51 (1.95) |
3.68 (2.07) |
3.92 (2.36) |
4.03 (2.23) |
4.29 (2.42) |
4.25 (2.18) |
4.33 (2.07) |
4.14 (1.89) |
4.27 (2.03) |
4.44 (2.32) |
4.59 (2.19) |
4.73 (2.29) |
4.81 (2.28) |
4.22 (2.22) |
Median [Min, Max] |
3.00 [1.00, 17.0] |
3.00 [1.00, 17.0] |
3.00 [1.00, 17.0] |
3.00 [1.00, 17.0] |
3.00 [1.00, 17.0] |
3.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 16.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 16.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
age_groups |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1-3 |
224 (64.6%) |
380 (64.0%) |
407 (64.5%) |
419 (63.2%) |
406 (59.3%) |
423 (53.7%) |
428 (48.5%) |
422 (42.3%) |
450 (41.0%) |
367 (37.6%) |
459 (42.5%) |
430 (38.9%) |
480 (38.1%) |
351 (31.8%) |
379 (30.3%) |
366 (27.4%) |
6391 (43.2%) |
4-5 |
94 (27.1%) |
154 (25.9%) |
164 (26.0%) |
180 (27.1%) |
202 (29.5%) |
267 (33.9%) |
336 (38.1%) |
416 (41.7%) |
456 (41.5%) |
432 (44.3%) |
441 (40.8%) |
473 (42.8%) |
536 (42.5%) |
507 (45.9%) |
553 (44.2%) |
627 (46.9%) |
5838 (39.4%) |
6-17 |
29 (8.4%) |
60 (10.1%) |
60 (9.5%) |
64 (9.7%) |
77 (11.2%) |
98 (12.4%) |
118 (13.4%) |
160 (16.0%) |
192 (17.5%) |
176 (18.1%) |
180 (16.7%) |
202 (18.3%) |
245 (19.4%) |
246 (22.3%) |
319 (25.5%) |
345 (25.8%) |
2571 (17.4%) |
narkozes_apmeklejums |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Primary |
323 (93.1%) |
540 (90.9%) |
583 (92.4%) |
616 (92.9%) |
627 (91.5%) |
726 (92.1%) |
827 (93.8%) |
939 (94.1%) |
1029 (93.7%) |
901 (92.4%) |
1012 (93.7%) |
1015 (91.9%) |
1153 (91.4%) |
990 (89.7%) |
1071 (85.6%) |
1127 (84.2%) |
13479 (91.1%) |
Repeated |
24 (6.9%) |
54 (9.1%) |
48 (7.6%) |
47 (7.1%) |
58 (8.5%) |
62 (7.9%) |
55 (6.2%) |
59 (5.9%) |
69 (6.3%) |
74 (7.6%) |
68 (6.3%) |
90 (8.1%) |
108 (8.6%) |
114 (10.3%) |
180 (14.4%) |
211 (15.8%) |
1321 (8.9%) |
apmaksas_veids |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Public |
347 (100%) |
594 (100%) |
631 (100%) |
629 (94.9%) |
468 (68.3%) |
505 (64.1%) |
511 (57.9%) |
473 (47.4%) |
424 (38.6%) |
510 (52.3%) |
399 (36.9%) |
387 (35.0%) |
453 (35.9%) |
323 (29.3%) |
531 (42.4%) |
800 (59.8%) |
7985 (54.0%) |
Privat |
0 (0%) |
0 (0%) |
0 (0%) |
34 (5.1%) |
217 (31.7%) |
283 (35.9%) |
371 (42.1%) |
525 (52.6%) |
674 (61.4%) |
465 (47.7%) |
681 (63.1%) |
718 (65.0%) |
808 (64.1%) |
781 (70.7%) |
720 (57.6%) |
538 (40.2%) |
6815 (46.0%) |
Grouping years
df %>%
select(pacienta_dzimums , vecums , age_groups , narkozes_apmeklejums , apmaksas_veids , year_group ) %>%
gtsummary::tbl_summary(by = year_group) %>%
bold_labels() %>%
as_gt() %>%
gt::gtsave(here("tables", "table1_3.html"))
table1::table1(
~ pacienta_dzimums + vecums + age_groups + narkozes_apmeklejums + apmaksas_veids | year_group,
data = df_sin
)
|
2005-2009 (N=2920) |
2010-2014 (N=4741) |
2015-2019 (N=5801) |
2020 (N=1338) |
Overall (N=14800) |
pacienta_dzimums |
|
|
|
|
|
Female |
1284 (44.0%) |
2069 (43.6%) |
2504 (43.2%) |
571 (42.7%) |
6428 (43.4%) |
Male |
1636 (56.0%) |
2672 (56.4%) |
3297 (56.8%) |
767 (57.3%) |
8372 (56.6%) |
vecums |
|
|
|
|
|
Mean (SD) |
3.55 (2.10) |
4.18 (2.26) |
4.44 (2.17) |
4.81 (2.28) |
4.22 (2.22) |
Median [Min, Max] |
3.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
4.00 [1.00, 17.0] |
age_groups |
|
|
|
|
|
1-3 |
1836 (62.9%) |
2090 (44.1%) |
2099 (36.2%) |
366 (27.4%) |
6391 (43.2%) |
4-5 |
794 (27.2%) |
1907 (40.2%) |
2510 (43.3%) |
627 (46.9%) |
5838 (39.4%) |
6-17 |
290 (9.9%) |
744 (15.7%) |
1192 (20.5%) |
345 (25.8%) |
2571 (17.4%) |
narkozes_apmeklejums |
|
|
|
|
|
Primary |
2689 (92.1%) |
4422 (93.3%) |
5241 (90.3%) |
1127 (84.2%) |
13479 (91.1%) |
Repeated |
231 (7.9%) |
319 (6.7%) |
560 (9.7%) |
211 (15.8%) |
1321 (8.9%) |
apmaksas_veids |
|
|
|
|
|
Privat |
251 (8.6%) |
2318 (48.9%) |
3708 (63.9%) |
538 (40.2%) |
6815 (46.0%) |
Public |
2669 (91.4%) |
2423 (51.1%) |
2093 (36.1%) |
800 (59.8%) |
7985 (54.0%) |
DEPENDENT VARIABLES
df %>%
ggplot(aes(x = kopa_estraheto_un_arsteto_zobu_skaits)) +
geom_histogram() +
stat_bin(binwidth = 1)

Number of filled and extracted teeth
df_sin %>%
summarise(mean(kopa_estraheto_un_arsteto_zobu_skaits), sd(kopa_estraheto_un_arsteto_zobu_skaits), mean(plombeto_zobu_skaits), sd(plombeto_zobu_skaits), mean(ekstraheto_zobu_skaits), sd(ekstraheto_zobu_skaits))
Supplement 3
df %>%
select(plombeto_zobu_skaits , ekstraheto_zobu_skaits , kopa_estraheto_un_arsteto_zobu_skaits , year ) %>%
gtsummary::tbl_summary(by = year) %>%
bold_labels() %>%
as_gt() %>%
gt::gtsave(here("tables", "table_supp_3.html"))
table1::table1(
~ plombeto_zobu_skaits + ekstraheto_zobu_skaits + kopa_estraheto_un_arsteto_zobu_skaits | year,
data = df_sin
)
|
2005 (N=347) |
2006 (N=594) |
2007 (N=631) |
2008 (N=663) |
2009 (N=685) |
2010 (N=788) |
2011 (N=882) |
2012 (N=998) |
2013 (N=1098) |
2014 (N=975) |
2015 (N=1080) |
2016 (N=1105) |
2017 (N=1261) |
2018 (N=1104) |
2019 (N=1251) |
2020 (N=1338) |
Overall (N=14800) |
plombeto_zobu_skaits |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mean (SD) |
5.61 (2.05) |
6.13 (2.12) |
6.09 (1.96) |
6.09 (1.99) |
6.15 (2.17) |
6.65 (2.21) |
7.08 (2.21) |
6.80 (2.23) |
6.55 (2.27) |
6.17 (2.19) |
5.81 (2.14) |
5.64 (2.07) |
5.05 (2.18) |
4.87 (2.12) |
5.01 (2.12) |
4.59 (2.55) |
5.80 (2.31) |
Median [Min, Max] |
6.00 [0, 14.0] |
6.00 [0, 12.0] |
6.00 [0, 12.0] |
6.00 [0, 16.0] |
6.00 [0, 12.0] |
7.00 [0, 14.0] |
7.00 [0, 16.0] |
7.00 [0, 13.0] |
7.00 [0, 14.0] |
6.00 [0, 17.0] |
6.00 [0, 16.0] |
6.00 [0, 12.0] |
5.00 [0, 12.0] |
5.00 [0, 14.0] |
5.00 [0, 12.0] |
5.00 [0, 12.0] |
6.00 [0, 17.0] |
ekstraheto_zobu_skaits |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mean (SD) |
1.34 (1.80) |
1.39 (1.91) |
1.94 (2.23) |
1.87 (2.27) |
2.14 (2.30) |
2.50 (2.60) |
2.12 (2.33) |
1.87 (2.30) |
1.99 (2.40) |
2.08 (2.41) |
1.84 (2.28) |
1.81 (2.23) |
1.87 (2.09) |
1.85 (2.15) |
1.79 (2.22) |
1.75 (2.14) |
1.90 (2.26) |
Median [Min, Max] |
0 [0, 8.00] |
0 [0, 10.0] |
1.00 [0, 11.0] |
1.00 [0, 14.0] |
2.00 [0, 14.0] |
2.00 [0, 19.0] |
1.00 [0, 11.0] |
1.00 [0, 17.0] |
1.00 [0, 15.0] |
1.00 [0, 14.0] |
1.00 [0, 20.0] |
1.00 [0, 15.0] |
1.00 [0, 13.0] |
1.00 [0, 14.0] |
1.00 [0, 15.0] |
1.00 [0, 15.0] |
1.00 [0, 20.0] |
kopa_estraheto_un_arsteto_zobu_skaits |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mean (SD) |
6.95 (2.69) |
7.53 (2.76) |
8.02 (2.70) |
7.96 (2.66) |
8.29 (2.75) |
9.15 (2.99) |
9.20 (2.96) |
8.67 (2.82) |
8.54 (2.96) |
8.25 (2.98) |
7.66 (2.79) |
7.45 (2.69) |
6.92 (2.64) |
6.72 (2.72) |
6.80 (2.79) |
6.34 (2.87) |
7.70 (2.94) |
Median [Min, Max] |
7.00 [1.00, 14.0] |
8.00 [1.00, 16.0] |
8.00 [1.00, 17.0] |
8.00 [1.00, 16.0] |
8.00 [1.00, 20.0] |
9.00 [1.00, 20.0] |
9.00 [1.00, 19.0] |
8.00 [1.00, 20.0] |
8.00 [1.00, 20.0] |
8.00 [1.00, 20.0] |
8.00 [1.00, 20.0] |
7.00 [1.00, 18.0] |
7.00 [1.00, 18.0] |
6.00 [1.00, 18.0] |
6.00 [1.00, 17.0] |
6.00 [1.00, 16.0] |
8.00 [1.00, 20.0] |
Other version of Supplement 3
df_sin %>%
arrange(desc(year)) %>%
group_by(year) %>%
summarise(bernu_skaits = n(),
kopa = sum(kopa_estraheto_un_arsteto_zobu_skaits),
kopa_vid = mean(kopa_estraheto_un_arsteto_zobu_skaits),
kopa_sd = sd(kopa_estraheto_un_arsteto_zobu_skaits),
plombetie = sum(plombeto_zobu_skaits),
plombetie_vid = mean(plombeto_zobu_skaits),
plombetie_sd = sd(plombeto_zobu_skaits),
ekstrahetie = sum(ekstraheto_zobu_skaits),
ekstrahetie_vid = mean(ekstraheto_zobu_skaits),
ekstrahetie_SD = sd(ekstraheto_zobu_skaits)
) %>%
mutate_if(is.numeric,round,2)
df_sin %>%
summarise(kopa = sum(kopa_estraheto_un_arsteto_zobu_skaits),
kopa_vid = mean(kopa_estraheto_un_arsteto_zobu_skaits),
kopa_sd = sd(kopa_estraheto_un_arsteto_zobu_skaits),
plombetie = sum(plombeto_zobu_skaits),
plombetie_vid = mean(plombeto_zobu_skaits),
plombetie_sd = sd(plombeto_zobu_skaits),
ekstrahetie = sum(ekstraheto_zobu_skaits),
ekstrahetie_vid = mean(ekstraheto_zobu_skaits),
ekstrahetie_SD = sd(ekstraheto_zobu_skaits)
)
INDEPENDENT VARIABLES
Gender
Recode if different names in one variable
table(df_sin$pacienta_dzimums)
##
## Female Male
## 6428 8372
df_sin %>%
select(pacienta_dzimums) %>%
gtsummary::tbl_summary()
Characteristic |
N = 14,800 |
pacienta_dzimums |
|
Female |
6,428 (43%) |
Male |
8,372 (57%) |
TABLE 3a
df_sin %>%
select(plombeto_zobu_skaits, ekstraheto_zobu_skaits, kopa_estraheto_un_arsteto_zobu_skaits, pacienta_dzimums) %>%
gtsummary::tbl_summary(by = pacienta_dzimums) %>%
add_difference() %>%
bold_labels() %>%
as_gt() %>%
gt::gtsave(here("tables", "table_3a.html"))
table1::table1(
~ plombeto_zobu_skaits + ekstraheto_zobu_skaits + kopa_estraheto_un_arsteto_zobu_skaits | pacienta_dzimums,
data = df_sin
)
|
Female (N=6428) |
Male (N=8372) |
Overall (N=14800) |
plombeto_zobu_skaits |
|
|
|
Mean (SD) |
5.73 (2.28) |
5.86 (2.34) |
5.80 (2.31) |
Median [Min, Max] |
6.00 [0, 16.0] |
6.00 [0, 17.0] |
6.00 [0, 17.0] |
ekstraheto_zobu_skaits |
|
|
|
Mean (SD) |
1.86 (2.22) |
1.93 (2.29) |
1.90 (2.26) |
Median [Min, Max] |
1.00 [0, 19.0] |
1.00 [0, 20.0] |
1.00 [0, 20.0] |
kopa_estraheto_un_arsteto_zobu_skaits |
|
|
|
Mean (SD) |
7.59 (2.89) |
7.78 (2.97) |
7.70 (2.94) |
Median [Min, Max] |
7.00 [1.00, 20.0] |
8.00 [1.00, 20.0] |
8.00 [1.00, 20.0] |
df_sin %>%
ggplot(aes(x = year, y = kopa_estraheto_un_arsteto_zobu_skaits,
color = pacienta_dzimums)) +
geom_boxplot() +
geom_jitter(alpha = 0.03) +
labs(
x = "year",
y = "n (teeth)"
)

Age
df_sin %>%
tabyl(vecums, year) %>%
adorn_totals("col")
df_sin %>%
ggplot(aes(x = vecums)) +
geom_histogram(bins = 17)

df_sin %>%
# group_by(pacienta_dzimums) %>%
summarise(mean_age = mean(vecums), sd = sd(vecums))
df %>%
select(vecums, year) %>%
gtsummary::tbl_summary(by = year)
Characteristic |
2005, N = 395 |
2006, N = 644 |
2007, N = 682 |
2008, N = 753 |
2009, N = 798 |
2010, N = 912 |
2011, N = 1,001 |
2012, N = 1,153 |
2013, N = 1,264 |
2014, N = 1,158 |
2015, N = 1,305 |
2016, N = 1,323 |
2017, N = 1,485 |
2018, N = 1,338 |
2019, N = 1,608 |
2020, N = 1,627 |
vecums |
3.0 (2.0, 4.0) |
3.0 (2.0, 4.0) |
3.0 (2.0, 4.0) |
3.0 (2.0, 4.0) |
3.0 (3.0, 5.0) |
4.0 (3.0, 5.0) |
4.0 (3.0, 5.0) |
4.0 (3.0, 5.0) |
4.0 (3.0, 5.0) |
4.0 (3.0, 6.0) |
4.0 (3.0, 6.0) |
4.0 (3.0, 6.0) |
4.0 (3.0, 6.0) |
4.0 (3.0, 6.0) |
5.0 (3.0, 7.0) |
4.0 (4.0, 6.0) |
Fig 2
df_sin %>%
mutate(vecums = as.integer(vecums)) %>%
group_by(year, vecums) %>%
filter(!is.na(vecums)) %>%
count() %>%
ggplot(aes(x = year,
y = n,
fill = as.factor(vecums))) +
geom_col(position="stack")

facet_grid(as.factor(vecums) ~ .)
## <ggproto object: Class FacetGrid, Facet, gg>
## compute_layout: function
## draw_back: function
## draw_front: function
## draw_labels: function
## draw_panels: function
## finish_data: function
## init_scales: function
## map_data: function
## params: list
## setup_data: function
## setup_params: function
## shrink: TRUE
## train_scales: function
## vars: function
## super: <ggproto object: Class FacetGrid, Facet, gg>
table(df_sin$age_groups)
##
## 1-3 4-5 6-17
## 6391 5838 2571
table1::table1(
~ age_groups | year,
data = df_sin
)
|
2005 (N=347) |
2006 (N=594) |
2007 (N=631) |
2008 (N=663) |
2009 (N=685) |
2010 (N=788) |
2011 (N=882) |
2012 (N=998) |
2013 (N=1098) |
2014 (N=975) |
2015 (N=1080) |
2016 (N=1105) |
2017 (N=1261) |
2018 (N=1104) |
2019 (N=1251) |
2020 (N=1338) |
Overall (N=14800) |
age_groups |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1-3 |
224 (64.6%) |
380 (64.0%) |
407 (64.5%) |
419 (63.2%) |
406 (59.3%) |
423 (53.7%) |
428 (48.5%) |
422 (42.3%) |
450 (41.0%) |
367 (37.6%) |
459 (42.5%) |
430 (38.9%) |
480 (38.1%) |
351 (31.8%) |
379 (30.3%) |
366 (27.4%) |
6391 (43.2%) |
4-5 |
94 (27.1%) |
154 (25.9%) |
164 (26.0%) |
180 (27.1%) |
202 (29.5%) |
267 (33.9%) |
336 (38.1%) |
416 (41.7%) |
456 (41.5%) |
432 (44.3%) |
441 (40.8%) |
473 (42.8%) |
536 (42.5%) |
507 (45.9%) |
553 (44.2%) |
627 (46.9%) |
5838 (39.4%) |
6-17 |
29 (8.4%) |
60 (10.1%) |
60 (9.5%) |
64 (9.7%) |
77 (11.2%) |
98 (12.4%) |
118 (13.4%) |
160 (16.0%) |
192 (17.5%) |
176 (18.1%) |
180 (16.7%) |
202 (18.3%) |
245 (19.4%) |
246 (22.3%) |
319 (25.5%) |
345 (25.8%) |
2571 (17.4%) |
TABLE 3b
df_sin %>%
select(plombeto_zobu_skaits , ekstraheto_zobu_skaits , kopa_estraheto_un_arsteto_zobu_skaits , age_groups) %>%
gtsummary::tbl_summary(by = age_groups) %>%
add_p() %>%
# add_difference() %>%
bold_labels() %>%
as_gt() %>%
gt::gtsave(here("tables", "table_3b.html"))
table1::table1(
~ plombeto_zobu_skaits + ekstraheto_zobu_skaits + kopa_estraheto_un_arsteto_zobu_skaits | age_groups,
data = df_sin
)
|
1-3 (N=6391) |
4-5 (N=5838) |
6-17 (N=2571) |
Overall (N=14800) |
plombeto_zobu_skaits |
|
|
|
|
Mean (SD) |
6.19 (2.27) |
5.83 (2.19) |
4.76 (2.37) |
5.80 (2.31) |
Median [Min, Max] |
6.00 [0, 14.0] |
6.00 [0, 17.0] |
5.00 [0, 16.0] |
6.00 [0, 17.0] |
ekstraheto_zobu_skaits |
|
|
|
|
Mean (SD) |
1.65 (2.14) |
1.83 (2.21) |
2.69 (2.47) |
1.90 (2.26) |
Median [Min, Max] |
1.00 [0, 19.0] |
1.00 [0, 20.0] |
2.00 [0, 15.0] |
1.00 [0, 20.0] |
kopa_estraheto_un_arsteto_zobu_skaits |
|
|
|
|
Mean (SD) |
7.83 (2.99) |
7.66 (2.83) |
7.45 (3.04) |
7.70 (2.94) |
Median [Min, Max] |
8.00 [1.00, 20.0] |
7.00 [1.00, 20.0] |
7.00 [1.00, 20.0] |
8.00 [1.00, 20.0] |
FIG 1
aa <- df_sin %>%
select(year, count, age_groups) %>%
group_by(year, age_groups) %>%
summarise(suma = sum(count)) %>%
ggplot(aes(x = year, y = suma, group = age_groups, color = age_groups)) +
geom_line(alpha = .3) +
geom_smooth() +
labs(
y = "n (patients)",
x = "Year",
color = "Age groups"
) +
theme_classic()
bb <- df_sin %>%
select(year, kopa_estraheto_un_arsteto_zobu_skaits, age_groups) %>%
group_by(year, age_groups) %>%
summarise(mean = mean(kopa_estraheto_un_arsteto_zobu_skaits)) %>%
ggplot(aes(x = year, y = mean, group = age_groups, color = age_groups)) +
geom_line(alpha = .3) +
geom_smooth() +
labs(
y = "n (teeth)",
x = "Year",
color = "Age groups"
) +
theme_classic()
ggarrange(aa, bb,
labels = c("A", "B"),
ncol = 2,
nrow = 1)

rm(aa, bb)
df_sin %>%
pivot_longer(kopa_estraheto_un_arsteto_zobu_skaits,
names_to = "manipulacijas",
values_to = "n_manipulacijas") %>%
select(arstesanas_datums, manipulacijas, n_manipulacijas, age_groups, year) %>%
group_by(year, manipulacijas, age_groups) %>%
summarise(sum_manipulacijas = sum(n_manipulacijas)) %>%
ggplot(aes(x = year, y = sum_manipulacijas, group = age_groups, color = age_groups)) +
geom_line() +
labs(
y = "Patients",
x = "Year",
color = "Age groups"
) +
# scale_y_log10() + # check proportional change
theme_classic()

FIG 3
cc <- df_sin %>%
pivot_longer(
ekstraheto_zobu_skaits:plombeto_zobu_skaits,
names_to = "tto",
values_to = "n_tto"
) %>%
mutate(tto = recode(tto, ekstraheto_zobu_skaits = "Extracted teeth")) %>%
mutate(tto = recode(tto, plombeto_zobu_skaits = "Filled teeth")) %>%
group_by(year, tto, age_groups) %>%
summarise(sum_tto = sum(n_tto)) %>%
ggplot(aes(
x = year,
y = sum_tto,
group = tto,
color = tto
)) +
geom_line() +
# scale_y_log10() +
facet_grid(age_groups ~ .) +
labs(y = "n (teeth)",
x = "Year",
color = "Type of treatment") +
theme_classic()
dd <- df_sin %>%
select(year, kopa_estraheto_un_arsteto_zobu_skaits, age_groups) %>%
group_by(year, age_groups) %>%
summarise(suma = sum(kopa_estraheto_un_arsteto_zobu_skaits)) %>%
ggplot(aes(x = year, y = suma, group = age_groups, color = age_groups)) +
geom_line(alpha = .3) +
geom_smooth() +
labs(
y = "n (teeth)",
x = "Year",
color = "Age groups"
) +
theme_classic()
ggarrange(dd, cc,
labels = c("A", "B"),
ncol = 2,
nrow = 1)

rm(cc, dd)
df_sin %>%
ggplot(aes(x = year, y = kopa_estraheto_un_arsteto_zobu_skaits,
color = age_groups)) +
geom_boxplot() +
geom_jitter(alpha = 0.03) +
labs(
x = "year",
y = "n (teeth)"
)

Public / Private
table(df_sin$apmaksas_veids)
##
## Privat Public
## 6815 7985
df_sin %>%
tabyl(pacienta_dzimums, apmaksas_veids) %>%
adorn_percentages("col") %>%
adorn_ns()
df_sin %>%
tabyl(age_groups, apmaksas_veids) %>%
adorn_percentages("col") %>%
adorn_ns()
df_sin %>%
tabyl(year, apmaksas_veids) %>%
adorn_percentages("row") %>%
adorn_ns()
TABLE 3c
df_sin %>%
select(plombeto_zobu_skaits , ekstraheto_zobu_skaits , kopa_estraheto_un_arsteto_zobu_skaits , apmaksas_veids) %>%
gtsummary::tbl_summary(by = apmaksas_veids) %>%
# add_p() %>%
add_difference() %>%
bold_labels() %>%
as_gt() %>%
gt::gtsave(here("tables", "table_3c.html"))
table1::table1(
~ plombeto_zobu_skaits + ekstraheto_zobu_skaits + kopa_estraheto_un_arsteto_zobu_skaits | apmaksas_veids,
data = df_sin
)
|
Privat (N=6815) |
Public (N=7985) |
Overall (N=14800) |
plombeto_zobu_skaits |
|
|
|
Mean (SD) |
5.82 (2.24) |
5.78 (2.37) |
5.80 (2.31) |
Median [Min, Max] |
6.00 [0, 17.0] |
6.00 [0, 16.0] |
6.00 [0, 17.0] |
ekstraheto_zobu_skaits |
|
|
|
Mean (SD) |
1.69 (2.09) |
2.08 (2.38) |
1.90 (2.26) |
Median [Min, Max] |
1.00 [0, 20.0] |
1.00 [0, 19.0] |
1.00 [0, 20.0] |
kopa_estraheto_un_arsteto_zobu_skaits |
|
|
|
Mean (SD) |
7.51 (2.86) |
7.86 (3.00) |
7.70 (2.94) |
Median [Min, Max] |
7.00 [1.00, 20.0] |
8.00 [1.00, 20.0] |
8.00 [1.00, 20.0] |
df_sin %>%
ggplot(aes(x = year, y = kopa_estraheto_un_arsteto_zobu_skaits,
color = apmaksas_veids)) +
geom_boxplot() +
geom_jitter(alpha = 0.03) +
labs(
x = "year",
y = "n (teeth)"
)

df_sin %>%
ggplot(aes(x = year, y = kopa_estraheto_un_arsteto_zobu_skaits,
color = apmaksas_veids)) +
geom_boxplot() +
geom_jitter(alpha = 0.01)

Primary repeated treatment
table(df_sin$narkozes_apmeklejums)
##
## Primary Repeated
## 13479 1321
df_sin %>%
select(pacienta_dzimums,
narkozes_apmeklejums) %>%
gtsummary::tbl_summary(by = narkozes_apmeklejums) %>%
gtsummary::add_p()
Characteristic |
Primary, N = 13,479 |
Repeated, N = 1,321 |
p-value |
pacienta_dzimums |
|
|
0.13 |
Female |
5,828 (43%) |
600 (45%) |
|
Male |
7,651 (57%) |
721 (55%) |
|
There are no differences in whether it is primary treatment whether
repeated between gender.
df_sin %>%
select(age_groups,
narkozes_apmeklejums) %>%
gtsummary::tbl_summary(by = narkozes_apmeklejums) %>%
gtsummary::add_p()
Characteristic |
Primary, N = 13,479 |
Repeated, N = 1,321 |
p-value |
age_groups |
|
|
<0.001 |
1-3 |
6,095 (45%) |
296 (22%) |
|
4-5 |
5,343 (40%) |
495 (37%) |
|
6-17 |
2,041 (15%) |
530 (40%) |
|
df_sin %>%
group_by(pacienta_personas_kods)%>%
count(sort = TRUE) %>%
write_csv(here("datasets_created", "n_atenciones_noninvalid.csv")) # save this result to a file
TABLE 3d
df_sin %>%
select(plombeto_zobu_skaits , ekstraheto_zobu_skaits , kopa_estraheto_un_arsteto_zobu_skaits , narkozes_apmeklejums) %>%
gtsummary::tbl_summary(by = narkozes_apmeklejums) %>%
# add_p() %>%
add_difference() %>%
bold_labels() %>%
as_gt() %>%
gt::gtsave(here("tables", "table_3d.html"))
table1::table1(
~ plombeto_zobu_skaits + ekstraheto_zobu_skaits + kopa_estraheto_un_arsteto_zobu_skaits | narkozes_apmeklejums,
data = df_sin
)
|
Primary (N=13479) |
Repeated (N=1321) |
Overall (N=14800) |
plombeto_zobu_skaits |
|
|
|
Mean (SD) |
5.92 (2.28) |
4.61 (2.30) |
5.80 (2.31) |
Median [Min, Max] |
6.00 [0, 17.0] |
4.00 [0, 16.0] |
6.00 [0, 17.0] |
ekstraheto_zobu_skaits |
|
|
|
Mean (SD) |
1.95 (2.30) |
1.40 (1.77) |
1.90 (2.26) |
Median [Min, Max] |
1.00 [0, 20.0] |
1.00 [0, 12.0] |
1.00 [0, 20.0] |
kopa_estraheto_un_arsteto_zobu_skaits |
|
|
|
Mean (SD) |
7.86 (2.92) |
6.01 (2.60) |
7.70 (2.94) |
Median [Min, Max] |
8.00 [1.00, 20.0] |
6.00 [1.00, 16.0] |
8.00 [1.00, 20.0] |
df_sin %>%
ggplot(aes(x = year, y = kopa_estraheto_un_arsteto_zobu_skaits,
color = narkozes_apmeklejums)) +
geom_boxplot() +
geom_jitter(alpha = 0.02) +
labs(
x = "year",
y = "n (teeth)"
)

df_sin %>%
ggplot(aes(x = year, y = kopa_estraheto_un_arsteto_zobu_skaits,
color = narkozes_apmeklejums)) +
geom_boxplot() +
geom_jitter(alpha = 0.01)

Disabled
table(df$invaliditate)
##
## No Yes
## 14800 2646
df %>%
drop_na() %>%
select(invaliditate,
pacienta_dzimums) %>%
gtsummary::tbl_summary(by = invaliditate) %>%
gtsummary::add_p()
Characteristic |
No, N = 14,738 |
Yes, N = 2,632 |
p-value |
pacienta_dzimums |
|
|
<0.001 |
Female |
6,399 (43%) |
986 (37%) |
|
Male |
8,339 (57%) |
1,646 (63%) |
|
df %>%
drop_na() %>%
select(invaliditate,
narkozes_apmeklejums) %>%
gtsummary::tbl_summary(by = invaliditate) %>%
gtsummary::add_p()
Characteristic |
No, N = 14,738 |
Yes, N = 2,632 |
p-value |
narkozes_apmeklejums |
|
|
<0.001 |
Primary |
13,423 (91%) |
1,555 (59%) |
|
Repeated |
1,315 (8.9%) |
1,077 (41%) |
|
df %>%
drop_na() %>%
select(invaliditate,
age_groups) %>%
gtsummary::tbl_summary(by = invaliditate) %>%
gtsummary::add_p()
Characteristic |
No, N = 14,738 |
Yes, N = 2,632 |
p-value |
age_groups |
|
|
<0.001 |
1-3 |
6,335 (43%) |
299 (11%) |
|
4-5 |
5,835 (40%) |
541 (21%) |
|
6-17 |
2,568 (17%) |
1,792 (68%) |
|
df %>%
drop_na() %>%
select(invaliditate,
apmaksas_veids) %>%
gtsummary::tbl_summary(by = invaliditate) %>%
gtsummary::add_p()
Characteristic |
No, N = 14,738 |
Yes, N = 2,632 |
p-value |
apmaksas_veids |
|
|
<0.001 |
Privat |
6,773 (46%) |
10 (0.4%) |
|
Public |
7,965 (54%) |
2,622 (100%) |
|
df %>%
group_by(pacienta_personas_kods) %>%
filter(invaliditate == "Yes") %>%
count(sort = TRUE) %>%
write_csv(here("datasets_created", "n_atenciones_invalid.csv")) # save this result to a file
FIG 3
pp <- df %>%
filter(!is.na(apmaksas_veids)) %>%
ggplot(aes(x = apmaksas_veids, y = kopa_estraheto_un_arsteto_zobu_skaits)) +
geom_boxplot() +
geom_jitter(alpha=0.015) +
labs(
x = "Type of payment",
y = "n (teeth)"
) +
theme_pubclean()
cg <- df_sin %>%
group_by(year, apmaksas_veids) %>%
count() %>%
ggplot(aes(x = year, y = n, group = apmaksas_veids, fill = apmaksas_veids)) +
geom_col(position = "fill") +
# scale_fill_manual(values = c("yellow", "darkgreen")) +
# scale_fill_viridis(discrete=TRUE) +
# scale_fill_brewer(palette="YIGnBu") +
labs(x = "Year",
y = "Proportion",
group = "Type of payment") +
geom_hline(yintercept=0.5, color = "red") +
theme_pubclean() +
theme(legend.position = "none")
np <- df_sin %>%
group_by(year) %>%
count() %>%
ggplot(aes(x = year, y = n )) +
geom_col() +
labs(
x = "Year",
y = "n (patients)"
) +
theme_pubclean() +
theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank()) +
ylim(0, 1500)
lg <- df_sin %>%
pivot_longer(kopa_estraheto_un_arsteto_zobu_skaits,
names_to = "manipulacijas",
values_to = "n_manipulacijas") %>%
select(manipulacijas, n_manipulacijas, year) %>%
group_by(year) %>%
summarise(average_manipulacijas = mean(n_manipulacijas) , sd_manipulacijas = sd(n_manipulacijas)) %>%
ggplot(aes(x = year, y = average_manipulacijas, group = 1)) +
# geom_errorbar(aes(ymin=average_manipulacijas-sd_manipulacijas, ymax=average_manipulacijas+sd_manipulacijas), width=.1, position = position_dodge(0.05)) +
geom_line() +
geom_point() +
labs(
x = "Year",
y = "n (teeth)"
) +
theme_pubclean() +
theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank()) +
ylim(5, 10)
ggarrange(pp,
labels = "A",
ncol = 2,
nrow = 1, ggarrange(lg, np, cg,
labels = c("B", "C", "D"),
ncol = 1,
nrow = 3),
widths = c(1,2))

ggsave(here("figures", "fig3.tiff"), width=180, height=130, units="mm", dpi=300, compression = "lzw")
rm(pp, cg, np, lg)
pl <- df_sin %>%
ggplot(aes(x = year, y = kopa_estraheto_un_arsteto_zobu_skaits,
color = apmaksas_veids)) +
geom_boxplot() +
geom_jitter(alpha = 0.03) +
labs(
x = "Year",
y = "n (teeth)"
)
cg <- df_sin %>%
group_by(year, apmaksas_veids) %>%
count() %>%
ggplot(aes(x = year, y = n, group = apmaksas_veids, fill = apmaksas_veids)) +
geom_col(position = "fill") +
# scale_fill_manual(values = c("yellow", "darkgreen")) +
# scale_fill_viridis(discrete=TRUE) +
# scale_fill_brewer(palette="YIGnBu") +
labs(x = "Year",
y = "Proportion",
group = "Type of payment") +
geom_hline(yintercept=0.5, color = "red") +
theme_pubclean() +
theme(legend.position = "none")
np <- df_sin %>%
group_by(year) %>%
count() %>%
ggplot(aes(x = year, y = n )) +
geom_col() +
labs(
x = "Year",
y = "n (patients)"
) +
theme_pubclean() +
theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank()) +
ylim(0, 1500)
lg <- df_sin %>%
pivot_longer(kopa_estraheto_un_arsteto_zobu_skaits,
names_to = "manipulacijas",
values_to = "n_manipulacijas") %>%
select(manipulacijas, n_manipulacijas, year) %>%
group_by(year) %>%
summarise(average_manipulacijas = mean(n_manipulacijas) , sd_manipulacijas = sd(n_manipulacijas)) %>%
ggplot(aes(x = year, y = average_manipulacijas, group = 1)) +
# geom_errorbar(aes(ymin=average_manipulacijas-sd_manipulacijas, ymax=average_manipulacijas+sd_manipulacijas), width=.1, position = position_dodge(0.05)) +
geom_line() +
geom_point() +
labs(
x = "Year",
y = "n (teeth)"
) +
theme_pubclean() +
theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank()) +
ylim(5, 10)
ggarrange(pl,
labels = "A",
ncol = 2,
nrow = 1, ggarrange(lg, np, cg,
labels = c("B", "C", "D"),
ncol = 1,
nrow = 3),
widths = c(4,3))

# 2. Save the plot to a pdf
# ggsave("fig2.pdf")
ggsave(here( "figures", "fig2.tiff"), width=180, height=130, units="mm", dpi=300, compression = "lzw")
rm(pl, cg, np, lg)
REGIONS
df %>%
drop_na() %>%
select(pacienta_dzivesvieta) %>%
gtsummary::tbl_summary() %>%
gtsummary::bold_labels()
Characteristic |
N = 17,370 |
pacienta_dzivesvieta |
|
Ārzemes |
58 (0.3%) |
Mazpilsētas, lauki |
7,155 (41%) |
Pilsēta |
2,463 (14%) |
Rīga |
7,694 (44%) |
df %>%
drop_na() %>%
group_by(year, pacienta_dzivesvieta) %>%
summarise(n = n()) %>%
ggplot(aes(x = year, y = n, fill = pacienta_dzivesvieta)) +
geom_col() +
labs(
title = "Number of treated children by Region",
y = "n patients (log10)",
x = "Year",
fill = "Region"
) +
scale_y_log10() +
theme_minimal() +
scale_fill_discrete(name = "Region", labels = c("Abroad", "Town, village, farm", "City", "Riga"))

df %>%
drop_na() %>%
group_by(year, pacienta_dzivesvieta) %>%
summarise(n = n()) %>%
ggplot(aes(x = year, y = n, fill = pacienta_dzivesvieta)) +
geom_col() +
labs(
title = "Number of treated children by Region",
y = "n (patients)",
x = "Year",
fill = "Region"
) +
theme_minimal() +
scale_fill_discrete(name = "Region", labels = c("Abroad", "Town, village, farm", "City", "Riga"))

df_sin %>%
drop_na() %>%
group_by(year, pacienta_dzivesvieta, age_groups) %>%
summarise(n = n()) %>%
ggplot(aes(x = year, y = n, fill = pacienta_dzivesvieta)) +
geom_col() +
facet_grid(age_groups~.) +
labs(
title = "Number of treated children by Region and Age group",
y = "n treatments (log10)",
x = "Year",
fill = "Region"
) +
# scale_y_log10() +
theme_minimal() +
scale_fill_discrete(name = "Region", labels = c("Abroad", "Town, village, farm", "City", "Riga"))

ggsave(here("figures", "fig4.tiff"), width=180, height=130, units="mm", dpi=300, compression = "lzw")