Skip to content

Commit

Permalink
12042019 am updates
Browse files Browse the repository at this point in the history
fixing DAWBA duplications
  • Loading branch information
georgiaoc committed Dec 4, 2019
1 parent f7c8f8e commit 43bbfdf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
11 changes: 6 additions & 5 deletions DAWBA_database_and_deletions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#***********DAWBA = diagnostic information from participant screening

# to do:
# dawba deletions
# bdd information

# Loading patient info ----------------------------------------------------

Expand Down Expand Up @@ -115,6 +113,7 @@ DAWBA_Archive <- read_excel(paste0(database_location, "other_data_never_delete/d
dawba_combined <- merge.default(DAWBA_Archive, DAWBA_Data_Download_raw, all=TRUE) %>%
filter(sid !="234110") %>% filter(sid !="234111") %>% filter(sid !="234112") %>% filter(sid !="234113") %>% filter(sid !="None")
fill_names <- dawba_combined %>% select(-sid) %>% colnames()
dawba_combined[fill_names] <- lapply(dawba_combined[fill_names], na_if, "")
dawba_combined <- dawba_combined %>%
group_by(sid) %>%
fill(., names(fill_names), .direction = "down") %>%
Expand All @@ -134,8 +133,6 @@ DAWBA_Data_Download <- dawba_combined %>% select(dawba_columns$new_name) %>% arr

# Clean up -------------------------------------------

count_na <- function(x) sum(is.na(x))

DAWBA_Data_Download$DAWBA_SEX[DAWBA_Data_Download$DAWBA_SEX==1] <- 'MALE'
DAWBA_Data_Download$DAWBA_SEX[DAWBA_Data_Download$DAWBA_SEX==2] <- 'FEMALE'

Expand Down Expand Up @@ -280,17 +277,21 @@ s_bdd_combined <- s_bdd_combined %>% mutate(s_dawba_bdd_diag = (as.numeric(s_daw

all_bdd_combined <- merge.default(s_bdd_combined, p_bdd_combined, all=TRUE)
fill_names <- all_bdd_combined %>% select(-DAWBA_ID) %>% colnames()
all_bdd_combined[fill_names] <- lapply(all_bdd_combined[fill_names], na_if, "")
all_bdd_combined <- all_bdd_combined %>% group_by(DAWBA_ID) %>%
fill(., names(fill_names), .direction = "down") %>%
fill(., names(fill_names), .direction = "up") %>%
distinct(., .keep_all = TRUE) %>% ungroup()

dawba_w_names <- merge.default(dawba_w_names, all_bdd_combined, all=TRUE)
fill_names <- dawba_w_names %>% select(-DAWBA_ID, -matches("date"), -matches("Date"), -DOB) %>% colnames()
dawba_w_names[fill_names] <- lapply(dawba_w_names[fill_names], na_if, "")
fill_names <- dawba_w_names %>% select(-DAWBA_ID) %>% colnames()
dawba_w_names <- dawba_w_names %>% group_by(DAWBA_ID) %>%
fill(., names(fill_names), .direction = "down") %>%
fill(., names(fill_names), .direction = "up") %>%
distinct(., .keep_all = TRUE) %>% ungroup()
arrange(DAWBA_ID, dawba_logins) %>% slice(1) %>%
ungroup()

# Exporting the database --------------------------------------------------

Expand Down
12 changes: 10 additions & 2 deletions Reports/Research_meeting_numbers.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,15 @@ if (exists("Psychometrics_treatment")==FALSE) {
}
if (exists("MEG_mprage")==FALSE) {
MEG_mprage <- read_excel(paste0(IRTA_tracker_location,"QCing/MEG_need_mprage.xlsx"))
meg_mprage_file <- list.files(path = paste0(IRTA_tracker_location, "QCing/"), pattern = "^MEG_need_mprage", all.files = FALSE,
full.names = FALSE, recursive = FALSE,
ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)
meg_mprage_file_time <- file.mtime(paste0(IRTA_tracker_location, "QCing/", meg_mprage_file)) %>% as.Date()
meg_mprage_combined <- tibble(File=c(meg_mprage_file), Date=c(meg_mprage_file_time)) %>%
arrange(desc(Date)) %>% slice(1)
MEG_mprage <- read_excel(paste0(IRTA_tracker_location, "QCing/", meg_mprage_combined[1]))
} else {
print("MEG MPRAGE missing info already imported")
}
Expand Down Expand Up @@ -851,7 +859,7 @@ current_inpatients %>% kable(., col.names = c("Initials", "Last Week Recorded",
rm(referrals_table3a, screens_table2, screens_current_table, ready_2_review, scheduled, scheduling_table2, protocol_table2,
inpatients_table, combined, meg_mmi_table2, meg_mmi_upcoming, bloods_table2,
current_outpatients, current_inpatients, outpatients, outpatients_table, inpatients, family_hist_table2,
supreme_table, meg_mprage_missing, MEG_mprage, diag_mid_3_table, fu_dates, mid_long)
supreme_table, meg_mprage_missing, diag_mid_3_table, fu_dates, mid_long)
rm(list=ls(pattern="denominator_"))
rm(list=ls(pattern="numerator_"))
Expand Down

0 comments on commit 43bbfdf

Please sign in to comment.