generated from opensafely/research-template
/
0a-snomedcheck.R
36 lines (24 loc) · 961 Bytes
/
0a-snomedcheck.R
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
# ##==============================================================================
# Analysis filename: 0a-snomedcheck
#
## ==============================================================================
## open log connection to file
sink(here::here("logs", "log-0a-snomedcheck.txt"))
library(skimr)
library(tidyverse)
library(here)
# create directory for saving tables, if not existent
if (!dir.exists(here::here("output", "tables"))){
dir.create(here::here("output", "tables"))
}
## import and pre-process cohort data
df_input <- read_csv(
here::here("output", "input_checksnomed.csv"))
#View(head(df_input))
print(df_input %>% select_if(is.numeric) %>% summarise_all(~sum(.,na.rm=T)))
print(skim(df_input))
print(summary(df_input))
df_summary <- df_input %>% select_if(is.numeric) %>% summarise_all(~sum(.,na.rm=T))
write.csv(df_summary,paste0(here::here("output","tables"),"/sc0a_snomedcheck_tallies.csv"))
## close log connection
sink()