Skip to content

Instantly share code, notes, and snippets.

View DavisVaughan's full-sized avatar

Davis Vaughan DavisVaughan

View GitHub Profile
@DavisVaughan
DavisVaughan / baby.txt
Created October 31, 2022 15:44
baby.txt
dummy
dummy
f1 <- function(...) {
data <- list(a = 100)
# Optionally, for performance if calling `eval_tidy()` a lot:
# data <- as_data_mask(data)
dots <- rlang::enquos(...)
n_dots <- length(dots)
out <- vector("list", length = n_dots)
> install.packages("lubridate")
Warning in install.packages :
package ‘lubridate’ is in use and will not be installed
library(tidyr)
library(dplyr)
df <- tibble(
g1 = c("x", "x", "y", "y", "y"),
g2 = factor(c("a", "a", "a", "b", "a"), levels = c("a", "b", "c"))
)
df
df %>%
library(tidyverse)
library(almanac)
library(clock)
# Define a recurrence rule for "all weekdays"
on_weekdays <- daily(since = "2012-01-01", until = "2022-12-31") %>%
recur_on_weekdays()
# Generate all of the "events" in the recurrence rule (i.e. all weekdays)
# then manipulate the results to get the day number per month
df <- tibble(
g = c(1, 1, 1, 1, 2, 2, 2, 2),
x = 1:8,
y = 8:1
)
# Group to show that this is applied per groups nicely
df <- group_by(df, g)
x <- df$x