Code
library(tidyverse)
library(gt)
library(readxl)
library(gtExtras)
library(devtools)
library(knitr)
write_bib(file = "packages.bib")
library(tidyverse)
library(gt)
library(readxl)
library(gtExtras)
library(devtools)
library(knitr)
write_bib(file = "packages.bib")
<- read_xlsx("SURVEY_DATA.xlsx")
DATA
<-
DATA %>%
DATA select(-where( ~ all(is.na(.)))) %>%
filter(`teilnahme[teilnahme]` == "Y")
<-
DATA 9:81] %>%
DATA[mutate(NA_CHECK = rowSums(!is.na(.))) %>%
filter(NA_CHECK > 0) %>%
filter(AB7 == 0) %>% # exclude special education schools
mutate(SED_INC = case_when(AB10 == 0 & AB11 == 0 ~ 0,
== 1 & AB11 == 0 ~ 1,
AB10 == 0 & AB11 == 1 ~ 2,
AB10 == 1 & is.na(AB11) ~ 1,
AB10 is.na(AB10) & AB11 == 1 ~ 2,
== 1 & AB11 == 1 ~ 3,
AB10 is.na(AB10) & is.na(AB11) ~ NA,
== 0 & is.na(AB11) ~ NA,
AB10 is.na(AB10) & AB11 == 0 ~ NA)) %>%
rename_with(~ stringr::str_replace_all(., "\\[", "_") %>%
::str_replace_all(., "\\]", "")) stringr
<-
describe function(var) {
%>%
DATA group_by({{var}}) %>%
reframe(n = n()) %>%
rename(V1 = names(.)[1]) %>%
mutate(percent = (n / sum(n))) %>%
mutate(INDEX = n) %>%
mutate(percent = (percent*100) %>% round(1)) %>%
relocate(percent, .after = last_col()) %>%
mutate(n = NULL)
}
<-
NAMES c("very high", "somewhat high", "somewhat low", "very low", "missing value",
"yes",
"yes", "missing value",
"yes",
"yes", "missing value",
"yes")
rbind(
describe(AB0 %>% factor(levels = 4:1)), # prior knowledge about epilepsy
describe(AB1) %>% slice(-1), # currently teaching students with epilepsy
describe(AB2) %>% slice(-1), # previously taught students with epilepsy
describe(AB3) %>% slice(-1), # witnessed a student having an epileptic seizure
describe(AB4) %>% slice(-1), # witnessed a person having an epileptic seizure
describe(AB5) %>% slice(-1) # have or have had regular contact with people with epilepsy
%>%
) mutate(V1 = NAMES) %>%
gt() %>%
gt_plt_bar_pct(column = percent,
scaled = T,
labels = TRUE,
fill = "black",
width = 100,
height = 20,
label_cutoff = 0.7,
font_size = "12px") %>%
cols_align("left") %>%
cols_label(V1 = "",
INDEX = md("***N***"),
percent = md("***%***")) %>%
tab_row_group(label = md("*have or have had regular contact with PWE (y/n)*"), rows = 12) %>%
tab_row_group(label = md("*witnessed a person having an epileptic seizure (y/n)*"), rows = 10:11) %>%
tab_row_group(label = md("*witnessed a student having an epileptic seizure (y/n)*"), rows = 9) %>%
tab_row_group(label = md("*previously taught students with epilepsy (y/n)*"), rows = 7:8) %>%
tab_row_group(label = md("*currently teaching students with epilepsy (y/n)*"), rows = 6) %>%
tab_row_group(label = md("*prior knowledge about epilepsy (self-rating)*"), rows = 1:5) %>%
tab_style(style = list(cell_text(indent = pct(10))), locations = cells_body(columns = V1)) %>%
tab_options(column_labels.background.color = "gray95",
footnotes.background.color = "gray95") %>%
tab_style(style = cell_fill(color = "gray95"), locations = cells_row_groups(groups = everything())) %>%
tab_footnote(md("*PWE = People with epilepsy*")) %>%
cols_align(align = "center", columns = starts_with("percent")) %>%
cols_align(align = "right", columns = starts_with("INDEX")) %>%
tab_options(table.align = "left")
N | % | |
---|---|---|
prior knowledge about epilepsy (self-rating) | ||
very high | 6 | 2.9% |
somewhat high | 37 | 17.6% |
somewhat low | 134 | 63.8% |
very low | 31 | 14.8% |
missing value | 2 | 1% |
currently teaching students with epilepsy (y/n) | ||
yes | 19 | 9% |
previously taught students with epilepsy (y/n) | ||
yes | 74 | 35.2% |
missing value | 2 | 1% |
witnessed a student having an epileptic seizure (y/n) | ||
yes | 35 | 16.7% |
witnessed a person having an epileptic seizure (y/n) | ||
yes | 93 | 44.3% |
missing value | 1 | 0.5% |
have or have had regular contact with PWE (y/n) | ||
yes | 47 | 22.4% |
PWE = People with epilepsy |
session_info()
## ─ Session info ───────────────────────────────────────────────────────────────
## setting value
## version R version 4.4.2 (2024-10-31 ucrt)
## os Windows 11 x64 (build 22631)
## system x86_64, mingw32
## ui RTerm
## language (EN)
## collate German_Germany.utf8
## ctype German_Germany.utf8
## tz Europe/Berlin
## date 2024-11-21
## pandoc 3.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date (UTC) lib source
## base64enc 0.1-3 2015-07-28 [1] CRAN (R 4.4.0)
## cachem 1.1.0 2024-05-16 [1] CRAN (R 4.4.2)
## cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.4.2)
## cli 3.6.3 2024-06-21 [1] CRAN (R 4.4.2)
## colorspace 2.1-1 2024-07-26 [1] CRAN (R 4.4.2)
## commonmark 1.9.2 2024-10-04 [1] CRAN (R 4.4.2)
## devtools * 2.4.5 2022-10-11 [1] CRAN (R 4.4.2)
## digest 0.6.37 2024-08-19 [1] CRAN (R 4.4.2)
## dplyr * 1.1.4 2023-11-17 [1] CRAN (R 4.4.2)
## ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.4.2)
## evaluate 1.0.1 2024-10-10 [1] CRAN (R 4.4.2)
## fansi 1.0.6 2023-12-08 [1] CRAN (R 4.4.2)
## fastmap 1.2.0 2024-05-15 [1] CRAN (R 4.4.2)
## fontawesome 0.5.3 2024-11-16 [1] CRAN (R 4.4.2)
## forcats * 1.0.0 2023-01-29 [1] CRAN (R 4.4.2)
## fs 1.6.5 2024-10-30 [1] CRAN (R 4.4.2)
## generics 0.1.3 2022-07-05 [1] CRAN (R 4.4.2)
## ggplot2 * 3.5.1 2024-04-23 [1] CRAN (R 4.4.2)
## glue 1.8.0 2024-09-30 [1] CRAN (R 4.4.2)
## gt * 0.11.1 2024-10-04 [1] CRAN (R 4.4.2)
## gtable 0.3.6 2024-10-25 [1] CRAN (R 4.4.2)
## gtExtras * 0.5.0 2023-09-15 [1] CRAN (R 4.4.2)
## hms 1.1.3 2023-03-21 [1] CRAN (R 4.4.2)
## htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.4.2)
## htmlwidgets 1.6.4 2023-12-06 [1] CRAN (R 4.4.2)
## httpuv 1.6.15 2024-03-26 [1] CRAN (R 4.4.2)
## jsonlite 1.8.9 2024-09-20 [1] CRAN (R 4.4.2)
## knitr * 1.49 2024-11-08 [1] CRAN (R 4.4.2)
## later 1.3.2 2023-12-06 [1] CRAN (R 4.4.2)
## lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.4.2)
## lubridate * 1.9.3 2023-09-27 [1] CRAN (R 4.4.2)
## magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.4.2)
## markdown 1.13 2024-06-04 [1] CRAN (R 4.4.2)
## memoise 2.0.1 2021-11-26 [1] CRAN (R 4.4.2)
## mime 0.12 2021-09-28 [1] CRAN (R 4.4.0)
## miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.4.2)
## munsell 0.5.1 2024-04-01 [1] CRAN (R 4.4.2)
## paletteer 1.6.0 2024-01-21 [1] CRAN (R 4.4.2)
## pillar 1.9.0 2023-03-22 [1] CRAN (R 4.4.2)
## pkgbuild 1.4.5 2024-10-28 [1] CRAN (R 4.4.2)
## pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.4.2)
## pkgload 1.4.0 2024-06-28 [1] CRAN (R 4.4.2)
## profvis 0.4.0 2024-09-20 [1] CRAN (R 4.4.2)
## promises 1.3.0 2024-04-05 [1] CRAN (R 4.4.2)
## purrr * 1.0.2 2023-08-10 [1] CRAN (R 4.4.2)
## R6 2.5.1 2021-08-19 [1] CRAN (R 4.4.2)
## Rcpp 1.0.13-1 2024-11-02 [1] CRAN (R 4.4.2)
## readr * 2.1.5 2024-01-10 [1] CRAN (R 4.4.2)
## readxl * 1.4.3 2023-07-06 [1] CRAN (R 4.4.2)
## rematch2 2.1.2 2020-05-01 [1] CRAN (R 4.4.2)
## remotes 2.5.0 2024-03-17 [1] CRAN (R 4.4.2)
## rlang 1.1.4 2024-06-04 [1] CRAN (R 4.4.2)
## rmarkdown 2.29 2024-11-04 [1] CRAN (R 4.4.2)
## rstudioapi 0.17.1 2024-10-22 [1] CRAN (R 4.4.2)
## sass 0.4.9 2024-03-15 [1] CRAN (R 4.4.2)
## scales 1.3.0 2023-11-28 [1] CRAN (R 4.4.2)
## sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.4.2)
## shiny 1.9.1 2024-08-01 [1] CRAN (R 4.4.2)
## stringi 1.8.4 2024-05-06 [1] CRAN (R 4.4.0)
## stringr * 1.5.1 2023-11-14 [1] CRAN (R 4.4.2)
## tibble * 3.2.1 2023-03-20 [1] CRAN (R 4.4.2)
## tidyr * 1.3.1 2024-01-24 [1] CRAN (R 4.4.2)
## tidyselect 1.2.1 2024-03-11 [1] CRAN (R 4.4.2)
## tidyverse * 2.0.0 2023-02-22 [1] CRAN (R 4.4.2)
## timechange 0.3.0 2024-01-18 [1] CRAN (R 4.4.2)
## tzdb 0.4.0 2023-05-12 [1] CRAN (R 4.4.2)
## urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.4.2)
## usethis * 3.0.0 2024-07-29 [1] CRAN (R 4.4.1)
## utf8 1.2.4 2023-10-22 [1] CRAN (R 4.4.2)
## vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.4.2)
## withr 3.0.2 2024-10-28 [1] CRAN (R 4.4.2)
## xfun 0.49 2024-10-31 [1] CRAN (R 4.4.2)
## xml2 1.3.6 2023-12-04 [1] CRAN (R 4.4.2)
## xtable 1.8-4 2019-04-21 [1] CRAN (R 4.4.2)
## yaml 2.3.10 2024-07-26 [1] CRAN (R 4.4.1)
##
## [1] C:/Users/Pawel Kulawiak/AppData/Local/Programs/R/R-4.4.2/library
##
## ──────────────────────────────────────────────────────────────────────────────