fillDown: fillDown fills a measurement down for a specific amount of...

Description Usage Arguments Value Examples

View source: R/fillDown.R

Description

For example, if you have a lab measurement and want it to be valid for the next 6 hours this function can be used to set the next 6 hours if no other measurment has been made. Only NA's are filled in.

Usage

1
fillDown(meas_col, time_col, carry_forward = lubridate::hours(6))

Arguments

meas_col

column to carry forward

time_col

column that defines what "time" a measurment is taken. Can be any data type that supports numeric operations.

carry_forward

how long to carry a measurement forward for. Must be the same type as 'time_col'

Value

vector type same as meas_col

Examples

1
2
3
4
5
6
7
library(dplyr)
set.seed(2)
d <- data.frame(meas = rnorm(100),
                time = 1:100)
d$meas[sample(1:nrow(d), 70)] <- NA
d %>%
  mutate(filled_meas = fillDown(meas, time, carry_forward = 3))

West-End-Statistics/r-library-vakdr documentation built on Dec. 18, 2021, 7:16 p.m.