Skip to content

Instantly share code, notes, and snippets.

@JosiahParry
JosiahParry / single-page-pkg-doc.R
Created April 14, 2024 16:13
Create a single page function reference using base R and quarto.
# Current limitation is that the images that are used are relative to the
# package lib.loc / help so what might be idea lis to extract the image
# and base64 encode them using {b64}
pkg_to_quarto_doc <- function(pkg, out_path = paste0(pkg, ".qmd"), ...) {
tmp <- tempfile()
base_doc <- tools::pkg2HTML(pkg, out = tmp, ...)
# read in html
og <- rvest::read_html(tmp)
@NONONOexe
NONONOexe / .commit_template
Last active February 2, 2025 05:22
My commit message template
# ============================== Format ==============================
# :emoji: Subject
#
# Commit body...
#
# ============================== Emojis ==============================
# 🎉 :tada: Initial commit
# ✨ :sparkles: Introduce new feature
# ⚡️ :zap: Inprove performance
@olivroy
olivroy / .Rprofile
Last active April 22, 2024 02:04
Deprecated, moved to elsewhere
# if (FALSE && rlang::is_interactive()) {
if (interactive() && !"rlang" %in% rownames(utils::installed.packages())) utils::install.packages("rlang", type = "binary")
# options(rlang_interactive = FALSE)
if (interactive()) rlang::check_installed(c("pak", "rprojroot", "tidyverse", "gt", "quarto", "skimr", "kit", "sf"))
# my packages
# if (interactive()) {
# invisible(pak::repo_add(sfirke = "https://sfirke.r-universe.dev", olivroy = "https://olivroy.r-universe.dev"))
# }
@rasmusab
rasmusab / bowling-t-test.R
Created February 20, 2023 16:45
A much improved bowling T-test in R
bowling_animation_urls <- c(
"0.01" = "https://i.imgur.com/Kn8CQbj.gif",
"0.05" = "https://i.imgur.com/HFTKdDL.gif",
"0.1" = "https://i.imgur.com/8Sw54Mz.gif",
"1" = "https://i.imgur.com/kjROdhj.gif"
)
# We need to download the animations to the session temp dirercorty to display
# them in the Rstudio Viever pane
bowling_animation_html <- sapply(bowling_animation_urls, function(url) {
@juliasilge
juliasilge / eurovision.md
Last active June 17, 2022 10:10
Eurovision voting from #TidyTuesday
library(tidyverse)
library(widyr)
library(maps)
#> 
#> Attaching package: 'maps'
#> The following object is masked from 'package:purrr':
#> 
#>     map
eurovision_votes <- read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-05-17/eurovision-votes.csv')
@gadenbuie
gadenbuie / render_toc.R
Last active April 24, 2025 09:54
Generate Manual Table of Contents in (R)Markdown Documents
#' Render Table of Contents
#'
#' A simple function to extract headers from an RMarkdown or Markdown document
#' and build a table of contents. Returns a markdown list with links to the
#' headers using
#' [pandoc header identifiers](http://pandoc.org/MANUAL.html#header-identifiers).
#'
#' WARNING: This function only works with hash-tag headers.
#'
#' Because this function returns only the markdown list, the header for the