Learn R Programming

amp.dm (version 0.2.0)

fill_dates: Fills down dates within a data frame that include a start and end date

Description

This function can be used in case a start and end date is known for dosing. This function fills down the dates so each date between start and end is placed on a separate row. Subsequently the dataset can be used to merge with available date information and impute missing dates.

Usage

fill_dates(data, start, end, tau = 1, repdat = 1)

Value

a data frame with filled out dates

Arguments

data

data frame for which the dates should be filled down

start

character identifying the start date (as date format) within the data frame

end

character identifying the end date (as date format) within the data frame

tau

integer with the tau in days (e.g. 2 for dosing every other day)

repdat

integer with repeats per day (e.g. 2 in case of twice daily dosing)

Author

Richard Hooijmaijers

Examples

Run this code

dfrm <- data.frame(ID=1:2,first=as.Date(c("2016-10-01","2016-12-01"), "%Y-%m-%d"),
                   last=as.Date(c("2016-10-03","2016-12-02"), "%Y-%m-%d"))
fill_dates(dfrm, "first", "last")
fill_dates(dfrm, "first", "last", 2, 3)

Run the code above in your browser using DataLab