-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.Rmd
119 lines (109 loc) · 3.31 KB
/
index.Rmd
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
108
109
110
111
112
113
114
115
116
117
118
119
---
title: "Steno Register-based Project: {{< var project.title >}}"
author:
- name: Luke W. Johnston
orcid: 0000-0003-4169-2616
affiliations:
- name: Steno Diabetes Center Aarhus
- name: Aarhus University
- name: Omar Silverman
affiliations:
- name: Steno Diabetes Center Aarhus
- name: Aarhus University
- name: Gunnar Toft
affiliations:
- name: Steno Diabetes Center Aarhus
- name: Aarhus University
---
The sidebar contains the applications sent to each of the different. If
you want to browse all the variables and registers we've requested, use
the table below.
## Searchable table
```{r setup}
#| message: false
#| warning: false
#| echo: false
#| column: page
#| tbl-cap: "Registers and variables requested from DST (as a searchable table)."
library(tidyverse)
library(here)
library(glue)
library(reactable)
source(here("R/functions.R"))
needed_registers <- here("data/needed-registers.csv") %>%
read_csv(col_types = "lddccccc") %>%
filter(!drop | is.na(drop))
dst_variables <- read_csv(here("data/dst-registers-with-variables-to-use.csv"))
dst_variables <- dst_variables %>%
filter(
register_id %in% unique(needed_registers$register_id)
) %>%
mutate(across(ends_with("year"), str_extract, pattern = "^\\d{4}")) %>%
mutate(
start_year = case_when(
is.na(variable_start_year) |
variable_start_year == variable_end_year ~
register_start_year,
TRUE ~ variable_start_year
),
year_range = glue::glue("{start_year} - {variable_end_year}")
) %>%
mutate(across(ends_with("year"), as.numeric))
sds_variables <- read_csv(here("data/sds-registers-with-variables-to-use.csv"))
sds_variables <- sds_variables %>%
mutate(periode = str_replace(periode, "\\s?-\\s?$", "-Latest")) %>%
mutate(
start_year = str_extract(periode, "^\\d{4}"),
end_year = str_extract(periode, "-\\d{4}$")
) %>%
mutate(across(ends_with("year"), as.numeric))
random_registers <- read_csv(here("data/random-undocumented.csv")) %>%
mutate(
start_year = if_else(is.na(start_year), "Earliest", as.character(start_year)),
year_range = glue::glue("{start_year} - {end_year}")
) %>%
mutate(across(ends_with("year"), as.numeric))
joined_registers <- list(
dst_variables %>%
select(
"Register ID" = register_id,
"Register" = register_name_dk,
"Variable" = variable_name,
"Start year" = variable_start_year,
"End year" = variable_end_year,
"Description" = description_english,
),
sds_variables %>%
select(
"Register" = register_name,
"Database Table" = table_name,
"Variable" = variable_name,
"Start year" = start_year,
"End year" = end_year,
"Description" = variable_description
),
random_registers %>%
select(
"Register" = register_name,
"Database Table" = register_table_name,
"Variable" = variable_name,
"Start year" = start_year,
"End year" = end_year,
"Description" = variable_description_dk
)
) %>%
reduce(bind_rows)
joined_registers %>%
as_reactable()
```
## Full variable list
```{r}
#| message: false
#| warning: false
#| echo: false
#| column: page
#| tbl-cap: "Registers and variables requested from DST (fully displayed list)."
options(knitr.kable.NA = "")
joined_registers %>%
knitr::kable()
```