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
| # update-pkgs.R | |
| # | |
| # Update all installed R packages (CRAN + Bioconductor, if BiocManager is | |
| # installed) in one non-interactive run. Designed to be launched with | |
| # Rscript, e.g. from a background process, instead of RStudio's | |
| # Tools > Check for Package Updates (which is slow and blocks the GUI). | |
| # | |
| # Usage (terminal command line): | |
| # Rscript.exe path/to/update-pkgs.R | |
| # |
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
| # Pull your GitHub commit history via the GraphQL API | |
| # | |
| # What was I working on, and when? How does work on one project relate to | |
| # others? This pulls commit history for a hand-picked list of repos into one | |
| # tidy dataset, so you can answer that with data instead of memory. | |
| # | |
| # --------------------------------------------------------------------------- | |
| # What it does | |
| # --------------------------------------------------------------------------- | |
| # Pulls commits and their attributes from GitHub directly via `gh api |
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
| # chunks.R | |
| # Parse the R code chunks in a Quarto/knitr book project into a data frame, | |
| # one row per chunk, so you can audit code-folding, find figure chunks that | |
| # still need treatment, spot old-style chunk labels, etc. See "Mind Your | |
| # Chunks" (friendly.github.io) for the full writeup. | |
| # | |
| # Usage: run from the project root. Adapt `chapter_files` / `child_files` | |
| # below to match your own project's file-naming convention -- as written, | |
| # this assumes chapter source files are named like "04-something.qmd" in | |
| # the working directory, with any knitr child documents listed explicitly. |
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
| #' Include an HTML-renderable object in any knitr output format | |
| #' | |
| #' A pipe-friendly helper in Rmarkdown, Quarto, and other documents for objects that render natively in HTML output | |
| #' (RStudio Viewer, HTML documents) but need a convenient image fallback for PDF, Word, | |
| #' and other non-HTML formats. It was designed to solve a problem in rendering the result of `color_table()`, | |
| #' and then generalized to provide for other similar cases. | |
| #' | |
| #' Supported classes (handled internally) solve this problem by saving the image to a file and then inserting it in the document | |
| #' using `knitr::include_graphics()`: | |
| #' - `"gt_tbl"` (gt package) -- saved via \code{\link[gt]{gtsave}} |
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
| # Happy Birthday, R! | |
| # R 1.0.0 was first released on February 29, 2000 | |
| # Celebrating 26 years of statistical computing! | |
| out_file <- "r_birthday_cake.png" | |
| png(out_file, width = 800, height = 660, bg = "#FFF0F5") | |
| par(mar = c(0.3, 0.3, 0.3, 0.3), bg = "#FFF0F5") | |
| plot(0, 0, type = "n", xlim = c(0, 10), ylim = c(0, 10), | |
| axes = FALSE, xlab = "", ylab = "") | |
| rect(-1, -1, 11, 11, col = "#FFF0F5", border = NA) |
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
| #!/usr/bin/env Rscript | |
| # Functions to fix one of the awful things that `Rd2roxygen::Rd2roxygen()` does when it tries to convert | |
| # a package to use roxygen documentation | |
| # | |
| # * Fixes roxygen2 \item formatting used in \describe{} blocks to document arguments and elements of returned results | |
| # * Changes \item{list("VarName")} to \item{\code{VarName}} | |
| # | |
| # Usage: | |
| # From R: source("fix_roxygen_items.R"); fix_roxygen_items("R/data.R") |
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
| --- | |
| title: "Distribution of Determinants of 3×3 Matrices from {1,2,...,9}" | |
| author: "Michael Friendly" | |
| date: "`r Sys.Date()`" | |
| output: | |
| html_document: | |
| toc: true | |
| toc_float: true | |
| code_folding: show | |
| theme: united |
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
| #' --- | |
| #' title: discriminant analysis demo | |
| #' author: Michael Friendly | |
| #' --- | |
| library(MASS) | |
| library(ggplot2) | |
| #library(candisc) | |
| library(dplyr) |
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
| #' Render text in color for Markdown / Quarto documents using LaTeX or CSS styles | |
| #' | |
| #' This function uses `\textcolor{}{}` from the `xcolor` package for LaTeX output | |
| #' or a CSS `<span>` for HTML output. | |
| #' | |
| #' Note that a color not defined in the `xcolor` package will trigger a latex error. | |
| #' e.g., `darkgreen` is not defined but can use: | |
| #' \definecolor{darkgreen}{RGB}{1,50,32} | |
| #' | |
| #' @param text Text to display, a character string |
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
| #' --- | |
| #' title: penguin colors | |
| #' author: Michael Friendly | |
| #' --- | |
| # Create consistent sets of colors for penguins examples | |
| # These specific colors are taken from https://github.com/srvanderplas/ggpcp-paper/blob/main/index.R | |
| # See the image at: https://allisonhorst.github.io/palmerpenguins/reference/figures/lter_penguins.png | |
| peng.colors <- function(shade=c("medium", "light", "dark")) { |
NewerOlder