Error: 'attrition' is not an exported object from 'namespace:rsample'

Viewed 690

I am using a book Hands on Machine Learning By Bradley Boehmke. i wrote following line to access the data but i gave this error.

attrition <- rsample::attrition Error: 'attrition' is not an exported object from 'namespace:rsample'

2 Answers

I used to have the same question when I went across it, but then I found out that now the attrition DataFrame belongs to modeldata package. simply use the following code:

# Load the required libraries first

my_libraries <- c("rsample","modeldata","caret", "h2o", "dplyr", 
"ggplot2")
lapply(my_libraries, require, character.only = T)

# update 24.12.2021: it is best to call the dataset like: 
data(attrition)
# **PROBLEM STATEMENT** here: there is a list of ordered factor variables, 
# which is not_possible for h2o to deal with.

# for Job attrition data
churn <- attrition %>% mutate_if(is.ordered, .funs = factor,ordered = F)  

# NOTE: funs() can create a list of function calls. 
churn.h2o <- as.h2o(churn)
churn.h2o %>% View()
library(modeldata)
data("attrition", package = "modeldata")
churn <- attrition %>% mutate_if(is.ordered, .funs = factor,ordered = F)
Related