Skip to contents

Add an observations column to the forecast data frame containing observations for each time point.

Usage

join_fcst_obs(df, obs)

Arguments

df

The forecast data frame.

obs

The observations data frame.

Value

The forecast data frame with an additional obs column containing observations.

Examples

# data.frame(time=1:3, raw=4:6, obs=8:10)
casteval:::join_fcst_obs(data.frame(time=1:3, val=4:6), data.frame(time=0:4, val_obs=7:11))
#>   time val val_obs
#> 1    1   4       8
#> 2    2   5       9
#> 3    3   6      10

# remove rows with missing observations
# data.frame(time=3, val_q50=6, val_obs=7)
casteval:::join_fcst_obs(
  data.frame(time=1:3, val_q50=4:6),
  data.frame(time=2:3, val_obs=c(NA,7))
)
#>   time val_q50 val_obs
#> 1    3       6       7

# default behaviour is to error if observations are missing
try(casteval:::join_fcst_obs(
  data.frame(time=1:3, val_q50=4:6),
  data.frame(time=2:3, val_obs=c(NA,7))
))
#>   time val_q50 val_obs
#> 1    3       6       7