This method uses gather on an rset object to stack all of the non-ID or split columns in the data and is useful for stacking model evaluation statistics. The resulting data frame has a column based on the column names of data and another for the values.

# S3 method for rset
gather(
  data,
  key = NULL,
  value = NULL,
  ...,
  na.rm = TRUE,
  convert = FALSE,
  factor_key = TRUE
)

Arguments

data

An rset object.

key, value, ...

Not specified in this method and will be ignored. Note that this means that selectors are ignored if they are passed to the function.

na.rm

If TRUE, will remove rows from output where the value column in NA.

convert

If TRUE will automatically run type.convert() on the key column. This is useful if the column names are actually numeric, integer, or logical.

factor_key

If FALSE, the default, the key values will be stored as a character vector. If TRUE, will be stored as a factor, which preserves the original ordering of the columns.

Value

A data frame with the ID columns, a column called model (with the previous column names), and a column called statistic (with the values).

Examples

library(rsample) cv_obj <- vfold_cv(mtcars, v = 10) cv_obj$lm_rmse <- rnorm(10, mean = 2) cv_obj$nnet_rmse <- rnorm(10, mean = 1) gather(cv_obj)
#> id model statistic #> 1 Fold01 lm_rmse 0.2057106 #> 2 Fold02 lm_rmse 1.6133574 #> 3 Fold03 lm_rmse 0.6221739 #> 4 Fold04 lm_rmse 1.9626400 #> 5 Fold05 lm_rmse 1.9196722 #> 6 Fold06 lm_rmse 1.2689681 #> 7 Fold07 lm_rmse 2.4054513 #> 8 Fold08 lm_rmse 1.9371069 #> 9 Fold09 lm_rmse 2.8798132 #> 10 Fold10 lm_rmse 1.9696502 #> 11 Fold01 nnet_rmse -0.3537264 #> 12 Fold02 nnet_rmse 3.3714905 #> 13 Fold03 nnet_rmse 0.4639264 #> 14 Fold04 nnet_rmse 0.6281649 #> 15 Fold05 nnet_rmse 1.5481473 #> 16 Fold06 nnet_rmse 1.2450459 #> 17 Fold07 nnet_rmse 0.1624949 #> 18 Fold08 nnet_rmse 2.8361670 #> 19 Fold09 nnet_rmse 1.0331194 #> 20 Fold10 nnet_rmse 0.3114896