fill_forward: given NA values fill them with the final non-na value

View source: R/RcppExports.R

fill_forwardR Documentation

given NA values fill them with the final non-na value

Description

given NA values fill them with the final non-na value

Usage

fill_forward(x)

Arguments

x

A numeric vector of values

Details

Works very well in context of dplyr to carry out last-observation-carried-foward for different individuals. It will NOT replace leading NA's

Examples

fill_forward(c(1.0, NA, 2))
fill_forward(c(NA, 1, NA, 2))
library(dplyr)
df <- data_frame(id = c(1, 1, 2, 2), obs = c(1.2, 4.8, 2.5, NA))
df %>% group_by(id) %>% mutate(obs_locf = fill_forward(obs))

metrumresearchgroup/PKPDmisc documentation built on Oct. 21, 2022, 9:41 a.m.