rmw_nest_for_modelling: Function to nest observational data before modelling with...

View source: R/rmw_nest_for_modelling.R

rmw_nest_for_modellingR Documentation

Function to nest observational data before modelling with rmweather.

Description

rmw_nest_for_modelling will resample the observations if desired, will test and prepare the data (with rmw_prepare_data), and return a nested tibble ready for modelling.

Usage

rmw_nest_for_modelling(
  df,
  by = "resampled_set",
  n = 1,
  na.rm = FALSE,
  fraction = 0.8
)

Arguments

df

Input data frame. Generally a time series of air quality data with pollutant concentrations and meteorological variables.

by

Variables within df which will be used for nesting. Generally, by will be "site" and "variable". "resampled_set" will always be added for clarity.

n

Number of resampling sets to create.

na.rm

Should missing values (NA) be removed from value?

fraction

Fraction of the observations to make up the training set.

Value

Nested tibble.

Author(s)

Stuart K. Grange

See Also

rmw_prepare_data, rmw_model_nested_sets, rmw_predict_nested_sets

Examples


# Load package
library(dplyr)

# Keep things reproducible
set.seed(123)

# Prepare example data for modelling, replicate observations twice too
data_london %>% 
  rmw_nest_for_modelling(by = c("site", "variable"), n = 2)
 

rmweather documentation built on Nov. 21, 2023, 5:06 p.m.