MAJOR=4
MINOR=44
DEVNAME=tty44
  /   ˆ{‹„„-i[D<†ªoZƒ›Ù«Ã462_‘I|¥‰ÓMdœv ©ƒ†ü+=ÃÂ Î    ‹      ¥“]oÓ0†ï÷+¾à.9M×´9F#©D¥~©BqáÆnc5±#Û¥Œ_OÒ­›ZÁÄ•¿¿~ßc›¾IçIöu1‚OÙt‹Ï'ãH€øå:AL³´[„½q4#@
ïë[Äý~î¯Cc7˜-±ðU9@ç­Ê}(¼ ìŠ¶sì
h!¹hZ ^ùR²±ò'˜5 Ùy§„`©VX±+¥Ãa…½àæ]À+1àVZ-K\;Ìe]Pì4U<ÊÒ•�íiÑ*7“|u8 íZF}?x©6:&ÞÔ„QUmÀÙ<&¨r£®J®·áF­	ðÒÇäÛ8™o8ôE»›Q…•ë˜|HâÙÝ<N	›ñJRäç™iÃÜ6áÎCã\­•á‡~P¿.¦“J—[U{eôŠMÄÓ¨¹)]Í›¬7M‚ÂžR"þVž?+Æâ~9šeéxÙ•D´Oî^yO„-¸•ÚCª¬Ì½±�Ç$�ì[½rõÝŸ!}Zµ)<a œ%_n§·Úìõi¾¦vg“µO*ÜÂŽ�S£/œõ{ýaEAÑûÛ¨pŒÂhz9Â?Þ"ß7ÅÃ¿¡ØýÒß ©E       ˆÁ�þB gÁ 7H ?Åƒh¹ÄÃÂ      MAJOR=4
MINOR=0
DEVNAME=tty0
  5   	ˆl–ßi~””Ëm
�Àã`S�ÿ�þe|k6V_‘¸ð ð?ŸÆƒe÷ÚÅÄÃ š    	## ---- include = FALSE---------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

options(rlang_backtrace_on_error = "none")

## ----setup--------------------------------------------------------------------
library(hardhat)
library(modeldata)

data(penguins)
penguins <- na.omit(penguins)

## -----------------------------------------------------------------------------
penguin_form <- mold(body_mass_g ~ log(bill_length_mm), penguins)

names(penguin_form)

## -----------------------------------------------------------------------------
penguin_form$predictors

## -----------------------------------------------------------------------------
penguin_form$outcomes

## -----------------------------------------------------------------------------
mold(body_mass_g ~ log(bill_length_mm) + offset(bill_depth_mm), penguins)$extras

## -----------------------------------------------------------------------------
identical(
  mold(~ body_mass_g, penguins), 
  mold(~ body_mass_g, penguins, blueprint = default_formula_blueprint())
)

## -----------------------------------------------------------------------------
no_intercept <- mold(~ body_mass_g, penguins)

no_intercept$predictors

## -----------------------------------------------------------------------------
with_intercept <- mold(
  ~ body_mass_g, penguins, 
  blueprint = default_formula_blueprint(intercept = TRUE)
)

with_intercept$predictors

## ---- error=TRUE--------------------------------------------------------------
mold(~ body_mass_g - 1, penguins)

mold(~ body_mass_g + 0, penguins)

## -----------------------------------------------------------------------------
expanded_dummies <- mold(~ body_mass_g + species, penguins)

expanded_dummies$predictors

## -----------------------------------------------------------------------------
non_expanded_dummies <- mold(
  ~ body_mass_g + species, penguins, 
  blueprint = default_formula_blueprint(indicators = "none")
)

non_expanded_dummies$predictors

## -----------------------------------------------------------------------------
k_cols <- mold(~ species, penguins)

k_minus_one_cols <- mold(
  ~ species, penguins, 
  blueprint = default_formula_blueprint(intercept = TRUE)
)

colnames(k_cols$predictors)

colnames(k_minus_one_cols$predictors)

## -----------------------------------------------------------------------------
.f <- cbind(body_mass_g, bill_length_mm) ~ bill_depth_mm

frame <- model.frame(.f, penguins)

head(frame)

## -----------------------------------------------------------------------------
ncol(frame)

class(frame$`cbind(body_mass_g, bill_length_mm)`)

head(frame$`cbind(body_mass_g, bill_length_mm)`)

## -----------------------------------------------------------------------------
multivariate <- mold(body_mass_g + log(bill_length_mm) ~ bill_depth_mm, penguins)

multivariate$outcomes

## -----------------------------------------------------------------------------
x <- subset(penguins, select = -body_mass_g)
y <- subset(penguins, select =  body_mass_g)

penguin_xy <- mold(x, y)

penguin_xy$predictors

penguin_xy$outcomes

## -----------------------------------------------------------------------------
xy_with_intercept <- mold(x, y, blueprint = default_xy_blueprint(intercept = TRUE))

xy_with_intercept$predictors

## ---------------------------------------------