Skip to content

Instantly share code, notes, and snippets.

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,
library(tidymodels)
library(rlang)
get_arg <- function(ns, f, arg) {
args <- formals(getFromNamespace(f, ns))
args <- args %>% as.list()
as.character(args[[arg]])
}
library(tidymodels)
library(modeldata)
data(attrition)
ord_rec <-
recipe(Attrition ~ JobInvolvement + JobSatisfaction, data = attrition) %>%
step_dummy(all_nominal()) %>%
prep() %>%
juice() %>%
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) %>%
# 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)
# ------------------------------------------------------------------------------
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(
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(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)]
## -----------------------------------------------------------------------------
# Simple demonstration of stacking using three models with the Ames housing data
## -----------------------------------------------------------------------------
library(tidymodels)
library(rules)
library(doMC)
library(AmesHousing)
library(ggforce)
@topepo
topepo / component_plot.R
Created July 10, 2020 01:37
first of two S3 methods for plotting PCA components
#' @param x A prepped recipe or fitted workflow that uses a recipe. The recipe
#' must have used at least one `step_pca()`.
#' @param id A single numeric or character value that is used to pick the step
#' with the PCA results. If a single `step_pca()` was used, this argument is
#' ignored. *Note*: if used, `id` must be named.
#' @param ... An optional series of conditional statements used to filter the
#' PCA data before plotting. See Details below.
#' @examples
#' library(recipes)
#' library(parsnip)