q.locf | R Documentation |
Perform "last observation carried forward" imputation on a dataset. If the first measurement is missing, the function also performs "first observation carried backward" imputation.
q.locf(db, sliceby=c())
db |
Data frame with missing values |
sliceby |
Fields by which the data should be split before imputation. This ensures that each imputation is only based on the same subject's data |
A data frame
Dataset needs to be ordered by subject ID and time, and any other characteristics. This ensures that only the previous measurement is used for imputation.
Abdul Malik Sulley <asulley@uwo.ca> April 5, 2020
zoo::na.locf
mybeaver <- beaver1 #order by day and time mybeaver <- mybeaver[order(mybeaver$day, mybeaver$time),] #make some data missing mybeaver$temp[c(6, 10, 22, 55, 57)] <- NA q.locf(mybeaver, sliceby="day")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.