prepare_data: Create train and test datasets given a formula and data

View source: R/tools.R

prepare_dataR Documentation

Create train and test datasets given a formula and data

Description

Create train and test datasets given a formula and data

Usage

prepare_data(
  formula,
  data,
  test_prop = 0,
  keep.var = NULL,
  drop_na = TRUE,
  spatial = FALSE,
  seed = NULL
)

Arguments

formula

the formula for the LMM or RF

data

the complete dataset

test_prop

the amount of rows to keep in the test dataset (default = 0)

keep.var

a vector of character strings indicating which variables to keep in the dataset on top of those defined by the formula

drop_na

whether to drop NAs or not (default = TRUE)

spatial

whether or not keeping predictor for fitting spatial effects (default = FALSE)

seed

an optional seed for the RNG

Examples

prepare_data(log(staff_rangers + 1) ~ log(GDP_2019) + Matern(1|long + lat),
             data = data_rangers, test_prop = 0.1)


courtiol/rangeRinPA documentation built on Sept. 29, 2022, 9:54 a.m.