library(PrePost)
library(dplyr)
library(yaml)
library(lubridate)
# Create an icdb::server object to access the ICB databases
svr <- icdb::server("XSW")
# Define a cohort to study - importing from an .csv file
cohort <- read.csv(system.file("extdata", "cohort-example4.csv", package="PrePost")) %>%
mutate(index_event_time=as.POSIXct(index_event_time))
# Define the type(s) of activity to look at and the filtering that defines them
# Importing from an .yaml file
activity_filter <- read_yaml(system.file("extdata", "activity_filter-example4.yaml", package="PrePost"))
# Create the PrePost object
obj <- PrePost(nhs_number = cohort$nhs_number,
index_event_time = cohort$index_event_time,
window_pre = 48,
window_post = 48,
window_units = "hours",
activity_filter = activity_filter,
svr = svr)
# Run the analysis
analyse(obj)