generated from opensafely/research-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add measure of recording completeness across practices
- Loading branch information
1 parent
4747d45
commit d7df3a7
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## Completeness of ethnicity recording by practice | ||
|
||
library(arrow) | ||
library("tidyverse") | ||
|
||
|
||
data <- read_feather(here::here("output", "extract_5", "input_5.feather")) | ||
|
||
data_count <- data %>% | ||
filter(registered == T) %>% | ||
summarise(practice, | ||
n = 1, | ||
recorded_ethnicity = case_when( | ||
!is.na(ethnicity_new_5) ~ 1, | ||
TRUE ~ 0 | ||
) | ||
) %>% | ||
group_by(practice) %>% | ||
summarise( | ||
n = sum(n), | ||
n_recorded_ethnicity = sum(recorded_ethnicity), | ||
completeness = n_recorded_ethnicity / n * 100 | ||
) %>% | ||
filter(n > 1000) %>% | ||
ungroup() %>% | ||
summarise( | ||
p05 = quantile(completeness, probs = seq(0, 1, 0.05), na.rm = TRUE)["5%"] %>% round(digits = 1), | ||
Q1 = quantile(completeness, na.rm = TRUE)["25%"] %>% round(digits = 1), | ||
median = median(completeness, na.rm = TRUE) %>% round(digits = 1), | ||
Q3 = quantile(completeness, na.rm = TRUE)["75%"] %>% round(digits = 1), | ||
p95 = quantile(completeness, probs = seq(0, 1, 0.05), na.rm = TRUE)["95%"] %>% round(digits = 1) | ||
) | ||
|
||
write_csv(data_count, here::here("output", "extract_5", "practice_completeness.csv")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters