Learn R Programming

rmweather (version 0.2.62)

rmw_nest_for_modelling: 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
)

Value

Nested tibble.

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.

Author

Stuart K. Grange

See Also

rmw_prepare_data, rmw_model_nested_sets, rmw_predict_nested_sets

Examples

Run this code

# 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)
 

Run the code above in your browser using DataLab