Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gather.rset

Gather an rset Object


Description

[Deprecated]

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. This method is now deprecated in favor of using tidyr::pivot_longer() directly.

Usage

## S3 method for class '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)

## now deprecated for rset objects:
gather(cv_obj)

## instead of gather, use tidyr::pivot_longer:
library(tidyr)
library(dplyr)
cv_obj %>%
  select(-splits) %>%
  pivot_longer(-id)

rsample

General Resampling Infrastructure

v0.1.0
MIT + file LICENSE
Authors
Julia Silge [aut, cre] (<https://orcid.org/0000-0002-3671-836X>), Fanny Chow [aut], Max Kuhn [aut], Hadley Wickham [aut], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.