Skip to content

Instantly share code, notes, and snippets.

## -----------------------------------------------------------------------------
# Simple demonstration of stacking using three models with the Ames housing data
## -----------------------------------------------------------------------------
library(tidymodels)
library(rules)
library(doMC)
library(AmesHousing)
library(ggforce)
library(tidymodels)
library(Matrix)
library(lobstr)
# ------------------------------------------------------------------------------
rand_values <- function (prefix = "step", len = 3, num_vals = Inf) {
candidates <- c(letters, LETTERS, paste(0:9))
candidates <- candidates[1:min(length(candidates), num_vals)]
library(tidyverse)
library(janitor)
library(tidymodels)
library(plotly)
theme_set(theme_bw())
body <-
read_csv("http://staff.pubhealth.ku.dk/~tag/Teaching/share/data/Bodyfat.csv") %>%
janitor::clean_names() %>%
library(tidyverse)
library(lubridate)
# ------------------------------------------------------------------------------
set.seed(2427)
hotels <-
readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-02-11/hotels.csv') %>%
filter(is_canceled == 0) %>%
mutate(
# devtools::install_dev("rsample")
library(tidymodels)
set.seed(252)
first_split <- initial_split(iris, p = 8/10)
test <- testing(first_split)
nrow(test)
others <- training(first_split)
library(tidyverse)
library(lubridate)
theme_set(theme_bw())
dat <-
read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv")
dat %>%
group_by(state) %>%
library(tidymodels)
library(modeldata)
data(attrition)
ord_rec <-
recipe(Attrition ~ JobInvolvement + JobSatisfaction, data = attrition) %>%
step_dummy(all_nominal()) %>%
prep() %>%
juice() %>%
library(tidymodels)
library(rlang)
get_arg <- function(ns, f, arg) {
args <- formals(getFromNamespace(f, ns))
args <- args %>% as.list()
as.character(args[[arg]])
}
replicates <- tibble::tribble(
~id, ~rep_1, ~rep_2,
"sample_001", 2.4061, 1.8369,
"sample_002", -0.6736, -0.102,
"sample_003", 1.0801, 0.7717,
"sample_004", 1.071, 1.5332,
"sample_005", 0.0674, 0.5275,
"sample_006", 1.6322, 1.8619,
"sample_007", -0.5528, -0.373,
"sample_008", 1.6413, 1.9207,
@topepo
topepo / flight_example.R
Created February 25, 2020 18:29
data analysis for nyc flights data set
library(tidymodels)
library(nycflights13)
set.seed(25213)
flight_data <-
flights %>%
mutate(
delay = ifelse(arr_delay >= 30, "late", "on_time"),
delay = factor(delay),
date = as.Date(time_hour)