powered by
This is useful when the gaps in a numeric timeseries can be filled with the same number (e.g. zero)
fill_na(dtf, varnames, with = 0)
tibble or data.frame
data.frame or tibble, first column of name datetime being of class datetime and rest of columns being numeric
datetime
character or vector of characters, column names with NA values
numeric, value to fill NA values
past_data <- data.frame( datetime = as.POSIXct("2024-01-01 00:00:00", tz = "UTC") + 0:3 * 3600, consumption = c(1.2, NA, NA, 2.5) ) fill_na(past_data, "consumption", with = 0)
Run the code above in your browser using DataLab