Skip to content

Instantly share code, notes, and snippets.

View gadenbuie's full-sized avatar

Garrick Aden-Buie gadenbuie

View GitHub Profile
@gadenbuie
gadenbuie / bslib-function-prefixes.md
Last active July 13, 2023 14:16
bslib function prefixes
View bslib-function-prefixes.md
library(tidyverse)

bsf <- pkgnet::FunctionReporter$new()
bsf$set_package("bslib")
bsf$calculate_default_measures()
bslib_fns <-
@gadenbuie
gadenbuie / 01-hello-dashboards.R
Last active October 28, 2023 20:57
Example apps using bslib v0.5.0
View 01-hello-dashboards.R
# https://shiny.posit.co/blog/posts/bslib-dashboards/#hello-dashboards
library(shiny)
library(bslib)
library(ggplot2)
# Setup -------------------------------------------------------------------
data(penguins, package = "palmerpenguins")
View httpuv-install.log
Installing package into ‘/Users/garrick/Library/R/arm64/4.3/library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/httpuv_1.6.10.tar.gz'
Content type 'application/x-gzip' length 1875497 bytes (1.8 MB)
==================================================
downloaded 1.8 MB
* installing *source* package ‘httpuv’ ...
** package ‘httpuv’ successfully unpacked and MD5 sums checked
** using staged installation
View yaml-chunk.Rmd
---
title: Reading a YAML chunk
output: github_document
---
Here's a simple YAML chunk (with the label `config`):
```{yaml config}
default:
user: "garrick"
@gadenbuie
gadenbuie / pkgdown-watch.R
Last active May 11, 2023 03:40
Watch a package and rebuild pkgdown docs when they change
View pkgdown-watch.R
#!/usr/bin/env -S Rscript --vanilla
rlang::check_installed(c("docopt", "pkgdown", "servr", "fs", "pkgload"))
'usage:
pkgdown-watch [--port=<port> --rebuild --no-sound]
pkgdown-watch -h | --help
options:
--port=<port> Port to use for the server [default: 4323]
View quarto-message-false.md
View migrate-rstudio-snippets-to-vscode.R
snps <-
list(r = "~/.config/rstudio/snippets/r.snippets") %>%
purrr::map(readLines, warn = FALSE) %>%
purrr::map(paste, collapse = "\n") %>%
purrr::map(trimws) %>%
purrr::map(strsplit, split = "(^|\n)snippet ") %>%
purrr::map_depth(2, ~ .x[.x != ""]) %>%
purrr::map_depth(2, ~ {
nm <- gsub("^([^\n\t ]+).*", "\\1", .x)
names(.x) <- nm
View cran-checks-history.R
library(tidyverse)
checks <- cchecks::cch_pkgs_history(x = "xaringanthemer", limit = 50)
checks$data$history |>
unnest(checks) |>
filter(status != "OK") |>
mutate(across(date_updated, lubridate::ymd_hms)) |>
arrange(date_updated) |>
mutate(
@gadenbuie
gadenbuie / r-code-for-wide-months.R
Created August 16, 2022 03:19
From date to month to columns with a crosstab
View r-code-for-wide-months.R
library(tidyverse)
library(lubridate)
# https://data.cityofchicago.org/Public-Safety/Crimes-2015/vwwp-7yr9
crimes <- read_csv("crimes.csv", lazy = TRUE, show_col_types = FALSE)
crimes |>
slice_sample(n = 500) |>
mutate(
Date = mdy_hms(Date),
View check-cran-incoming-checks.R
# These functions were borrowed from klmr/box
# https://github.com/klmr/box/tree/5e411d47/scripts
verify_function_has_value = function (file) {
rd = tools::parse_Rd(file)
type = find_tag(rd, 'docType')
(length(type) != 0L && type != 'function') || length(find_tag(rd, 'value')) != 0L
}
find_tag = function (rd, tag) {