library(here)here() starts at /home/micsac/Teaching/Courses/r-programming
med2005 <- readRDS(here("data", "med-2005-ex.rds"))Day 3, A
Michael C Sachs
In this lesson you will
lubridateFrom the data, download and read in the file “med-2005-ex.rds”.
lubridate package (try the function wday) to calculate the day of the week when the dispensation occurred. Do dispensations occur less frequently on weekends?dplyr or data.table to create a new variable that is the last dispensation for each individual during the year (using group_by then mutate or := with by). Then calculate the number of days between each dispensation and the last one. What is the average number of days?The “atc” variable contains the ATC code for the drug that was dispensed. This is a standardized classification system for drugs, see https://www.whocc.no/atc/structure_and_principles/.
grepl function with a pattern.