.fibs <- new.env()
.fib <- function(n) {
name <- as.character(n)
get0(name, envir = .fibs) %||% assign(name, fibonocci(n), envir = .fibs)
}
fibonocci <- function(n = 0) {
n <- floor(n)arg <- function(sym, type, default) {
sym <- substitute(sym)
spec <- structure(
list(
sym = as.character(sym),
type = type
),
class = "arg"
)enumerate <- function(x, i = "i", v = "v") {
lapply(
seq_along(x),
function(iteration) {
structure(
list(iteration, x[[iteration]]),
class = c("enumeration", "list"),
names = c(i, v)
)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| global_calling_handlers <- local({ | |
| . <- environment() | |
| class(.) <- c("cnd:global_calling_handlers", "environment") | |
| .handlers <- NULL | |
| handlers <- NULL | |
| add <- function(...) { | |
| "Adds calling handlers | |
| If handlers with the same name already exist, they are replaced. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pkg_version <- function(package, keep = c("all", "patch", "minor", "major")) { | |
| keep <- match.arg(keep) | |
| version <- utils::packageVersion(package) | |
| version <- unclass(version)[[1L]] | |
| version <- switch( | |
| keep, | |
| all = version, | |
| patch = version[1:3], | |
| minor = version[1:2], | |
| major = version[1L] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pak_install_pkgs <- function( | |
| pkg, | |
| new_lib = old_lib, | |
| old_lib = .libPaths()[1L], | |
| upgrade = FALSE, | |
| update = TRUE, | |
| dependencies = NA, | |
| force = FALSE, | |
| use_temp = FALSE, | |
| pak_lib = NULL |
library(S7)
typed <- function(fun, ...) {
..params <- list(...)
..syms <- names(..params)
stopifnot(..syms %in% names(formals(fun)))
# should make this a function
..validator <- S7::new_class("..validator", properties = ..params)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(plotly) | |
| library(htmlwidgets) | |
| x_unified_y_cursor <- " | |
| // hovermode is 'x unified' but we don't want the default y/vertical | |
| // positioning of the hover label. We want the hoverlabel to appear at the | |
| // current cursor position (i.e. the y position of the cursor) | |
| function(el) { | |
| el.on('plotly_hover', function(data) { | |
| console.log('event data: ', data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(progressr) | |
| library(furrr) | |
| handlers("void") | |
| handlers(list( | |
| handler_progress( | |
| format = ":spin :current/:total (:message) [:bar] :percent in :elapsed ETA: :eta", | |
| width = getOption("width"), | |
| complete = "=" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| invisible(lapply( | |
| list.files( | |
| path = ".", | |
| pattern = "\\.(r|rmd|qmd)$", | |
| full.names = TRUE, | |
| recursive = TRUE, | |
| ignore.case = TRUE | |
| ), | |
| function(path) { | |
| pat <- "!!rlang::sym[(]\"([a-zA-z0-9_]+)\"[)]" |
NewerOlder