Skip to content

Commit

Permalink
Merge pull request #87 from opensafely/practices
Browse files Browse the repository at this point in the history
add measure of recording completeness across practices
  • Loading branch information
andrewscolm authored May 8, 2024
2 parents 4747d45 + d7df3a7 commit beb6858
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
34 changes: 34 additions & 0 deletions analysis/practice_completeness.R
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"))
8 changes: 8 additions & 0 deletions project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ actions:
moderately_sensitive:
html: output/report/report.html

#### reviewer comments
practice_completeness:
run: r:latest analysis/practice_completeness.R
needs: [generate_study_population_5]
outputs:
moderately_sensitive:
csvs: output/extract_5/practice_completeness.csv

#### move released files to output/released
###### run locally for manuscript
##### local notebook
Expand Down

0 comments on commit beb6858

Please sign in to comment.