R Tutorial: Training a model with resampling