Skip to content
Snippets Groups Projects
Commit 1ed6757b authored by twillia2's avatar twillia2
Browse files

Upload New File

parent 87800253
No related branches found
No related tags found
No related merge requests found
##Script to create recruitment flowchart for BronchStop VE manuscript##
## Thomas Williams, University of Edinburgh ##
## January 2025 ##
#load packages
library(readxl)
library(dplyr)
library(tidyverse)
#set working directory
setwd("TBC")
#create list of files
file_list <- list.files(path="TBC")
#create empty dataframe
screening_log_df <- data.frame()
#loop to read in data, specify columns you want
for (i in 1:length(file_list)){
temp_data <- read_excel(file_list[i], range = cell_cols("A:G"))
print(file_list[i])
screening_log_df <- rbind(screening_log_df, temp_data)
}
#change column names
screening_log_tidy_headers <- screening_log_df %>%
rename( vaccine_eligible = `Vaccine eligible infant?* (Y/N) (if NO, data not required)`) %>%
rename( consented = `Mother Consented Y/N`) %>%
rename( reason_not_consented = `If Mother Not Consented, Reason`) %>%
rename( ID = `BRONCHSTART ID (If applicable)`)
#convert all lower case to upper case
screening_log_tidy_headers$consented <- toupper(screening_log_tidy_headers$consented)
#screen out cases were not eligible for Bronchstop and those that are yet to be contacted, often contain phrase "call next week or similar"
screening_log_BronchStop <- screening_log_tidy_headers %>%
filter(vaccine_eligible == "Y") %>%
filter_at(vars(consented), all_vars(!is.na(.))) %>%
filter(!grepl("still to contact",Notes)) %>%
filter(!grepl("HAS PIS still trying to contact",Notes)) %>%
filter(!grepl("to be contacted",Notes)) %>%
filter(!grepl("For a call next week",Notes))
#now look at reasons for exclusion
flowchart_results_screening <- screening_log_BronchStop %>%
group_by(consented, reason_not_consented, Notes)%>%
count(consented)
#now create table for flowchart
flowchart_for_paper <- screening_log_BronchStop %>%
group_by(consented, reason_not_consented) %>%
count(consented)
#write to file
write.csv(flowchart_for_paper, file = "TBC")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment