DHSC-Capstone/ML/0-data_prep.R

52 lines
1.1 KiB
R
Raw Normal View History

2023-01-05 08:18:18 -05:00
rm(list = ls(all.names = TRUE)) # Clear the memory of variables from previous run.
cat("\014") # Clear the console
# load packages -----------------------------------------------------------
box::use(
magrittr[`%>%`]
,RSQLite
,DBI[dbConnect,dbDisconnect]
,here[here]
2023-01-05 15:27:20 -05:00
,dplyr
2023-01-05 08:18:18 -05:00
)
# globals -----------------------------------------------------------------
db <- dbConnect(
RSQLite$SQLite()
,here("ML","data-unshared","mimicDB.sqlite")
)
2023-01-05 15:27:20 -05:00
test_list <- c(
50862 #Albumin
,50863 #Alkaline Phosphatase
,50861 #Alanine Aminotransferase (ALT)
,50878 #Asparate Aminotransferase (AST)
,51006 #Urea Nitrogen
,50893 #Calcium, Total
,50882 #Bicarbonate
,50902 #Chloride
,50912 #Creatinine
,50931 #Glucose
,50971 #Potassium
,50983 #Sodium
,50885 #Bilirubin, Total
,50976 #Protein, Total
,50993 #Thyroid Stimulating Hormone
,50995 #Thyroxine (T4), FreE
)
2023-01-05 08:18:18 -05:00
2023-01-05 15:27:20 -05:00
# load data ---------------------------------------------------------------
2023-01-05 08:18:18 -05:00
2023-01-05 15:27:20 -05:00
ds <- dplyr$tbl(db, "labevents") %>% dplyr$filter(itemid %in% test_list) %>% dplyr$collect()
2023-01-05 08:18:18 -05:00
# close database ----------------------------------------------------------
dbDisconnect(db)