Skip to content

Instantly share code, notes, and snippets.

View DavisVaughan's full-sized avatar

Davis Vaughan DavisVaughan

View GitHub Profile
@DavisVaughan
DavisVaughan / hop.R
Created May 2, 2024 13:47
hop-with-window-param
blah
@DavisVaughan
DavisVaughan / rap-demo.R
Created November 28, 2018 13:52
rap with models
suppressPackageStartupMessages({
library(rap)
library(AmesHousing)
library(rsample)
library(parsnip)
library(dplyr)
})
ames <- make_ames()
library(dplyr)
library(slider)
library(lubridate)
library(tsibbledata)
# Google, Apple, Facebook, Amazon stock
gafa_stock <- as_tibble(gafa_stock)
gafa_stock <- select(gafa_stock, Symbol, Date, Close, Volume)
head(gafa_stock, 2)
@DavisVaughan
DavisVaughan / zone-transitions.R
Created March 24, 2023 14:59
zone-transitions
library(clock)
library(purrr)
library(vctrs)
library(tibble)
generate_transitions <- function(zone,
from = date_build(1900, 1, 1),
to = date_build(2030, 1, 1)) {
days <- date_seq(
from = from,
@DavisVaughan
DavisVaughan / spooky.txt
Created October 31, 2022 15:57
spooky.txt
dummy
dummy
@DavisVaughan
DavisVaughan / baby.txt
Created October 31, 2022 15:44
baby.txt
dummy
dummy
@DavisVaughan
DavisVaughan / lm-hell.r
Created May 31, 2019 19:38
Exploring the object size of `lm()` objects with enclosing environments
library(purrr)
library(lobstr)
library(glue)
library(rlang, warn.conflicts = FALSE)
make_an_lm <- function() {
x <- rep(1L, times = 10000000)
cat(glue("x is {object.size(x)}B"))
lm(1 ~ 1)
}
# often package developers store the call in their model object
# and then print it out in their summary / print methods
lm_model <- lm(mpg ~ cyl, mtcars)
lm_model
#>
#> Call:
#> lm(formula = mpg ~ cyl, data = mtcars)
#>
#> Coefficients: