Skip to content

Instantly share code, notes, and snippets.

View DavisVaughan's full-sized avatar

Davis Vaughan DavisVaughan

View GitHub Profile
@DavisVaughan
DavisVaughan / r-print.c
Last active September 20, 2024 09:38
r-print-value-from-c
#include <R_ext/Parse.h>
const char* r_print_value(SEXP x) {
// Assign `x` into the global environment under the name `.debug`
Rf_defineVar(Rf_install(".debug"), x, R_GlobalEnv);
// This is the R code that we want to run to print `.debug` and then capture all its printed output
const char* command = "paste0(capture.output(print(.debug)), collapse = '\n')";
SEXP command_sexp = PROTECT(Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(command_sexp, 0, Rf_mkCharCE(command, CE_UTF8));
Apply Lionel's patches
wget https://raw.githubusercontent.com/lionel-/contributing/master/inst/GNUmakefile
wget https://raw.githubusercontent.com/lionel-/contributing/master/inst/make-svn-revision
chmod +x make-svn-revision
brew install wget if you don't have it
@DavisVaughan
DavisVaughan / hop.R
Created May 2, 2024 13:47
hop-with-window-param
blah
@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
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)