fill.missing: Fill missing values in an xts object

View source: R/functions.r

fill.missingR Documentation

Fill missing values in an xts object

Description

Fill missing entries in an xts object using nalocf or, alternatively, with an constant value

Usage

fill.missing(
  x,
  start = NULL,
  end = NULL,
  steps = "hour",
  fill = TRUE,
  na.value = NA
)

Arguments

x

an xts object

start

NULL or an POSIXct object. If NULL, the first index of x will be used

end

NULL or an POSIXct object. If NULL, the last index of x will be used

steps

increment of the sequence. See ‘Details’

fill

logical. If TRUE missing entries are filled using nalocf, else missing entries are filled with na.value

na.value

numeric or NA. Used for filling missing entries if fill == FALSE

Details

steps can be a character string, containing one of "sec", "min", "hour", "day", "DSTday", "week", "month", "quarter" or "year". Default is "hour"

Value

an xts object

Author(s)

Simon Frey

See Also

missing.steps

Examples

data("runoff")
# delete a row to make the time series irregulat
runoff.missing <- runoff[-4,]
# fill missing timesteps
runoff.filled <- fill.missing(runoff.missing)
### fill with -0.01
runoff.filled <- fill.missing(runoff.missing, fill = FALSE, na.value = -0.01)

freysimon/TigR documentation built on April 20, 2024, 9:28 p.m.