This file contains 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")) { |
This file contains 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: Animate transition from PCA <--> tsne | |
#' --- | |
# idea from: https://jef.works/genomic-data-visualization-2024/blog/2024/03/06/akwok1/ | |
#' ## Load packages and data | |
library(ggplot2) | |
library(gganimate) | |
library(Rtsne) | |
library(patchwork) |
This file contains 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
#' Demonstrate Effect of Measurement Error in Regression | |
#' | |
#' This function takes a variables x and y and demonstrates the effect of adding random normal errors | |
#' to one or both of the coordinates. For each level of \code{err}, it adds \code{rnorm(0, err * SD)} | |
#' to the corresponding x and/or y and displays the data points, a data ellipse and the fitted | |
#' regression line overlaid on the corresponding plot of the un-perturbed data. | |
#' | |
#' My thought was to make this general, to be used either in an interactive demonstration or an animated | |
#' graphic using the \pkg{animate} package. There is something wrong with my logic, because it doesn't | |
#' work for an interactive demo. |
This file contains 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
#' Generate Outline Documentation for a Data Set in Roxygen Format | |
#' | |
#' Generates a shell of documentation for a data set or other object in roxygen format. | |
#' This function was created by editing \code{\link[utils]{promptData}} to replace | |
#' the old style \code{.Rd} formatting with code suitable for processing with \code{\link[devtools]{document}}. | |
#' | |
#' @details | |
#' Unless \code{filename} is \code{NA}, a documentation shell for \code{object} is written in roxygen format to the file specified | |
#' by \code{filename}, and a message about this is given. | |
#' |
This file contains 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
#' Generate a BibTeX file of all installed packages | |
#' | |
#' This function finds all packages installed in your R library and calls | |
#' `citation()` for each, collecting the BibTeX entries and writing these to | |
#' a file. It handles situations where there are multiple citations for a package. | |
#' | |
#' @param filename Name of the .bib file to write to. | |
#' @param header Include a header giving `sessionInfo()` ? | |
#' @param preamble Preamble for the BibTeX file | |
#' @param prefix String to prefix the in the bibtex key |
This file contains 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
# Accumulating R package references in a Quarto book | |
In writing a book using Quarto, I was looking for a way to automatically | |
accumulate the packages used in each chapter and write them out to a `pkgs.bib` | |
file at the end. (I posted this as a Posit Community question, | |
https://community.rstudio.com/t/how-to-accumulate-packages-bib-used-in-a-quarto-book/167619 ) | |
I can easily do this with a `knitr` vignette, where the essence | |
is to include a chunk at the end, |
This file contains 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
#' Extract information about two-way terms in a loglinear model | |
#' | |
#' This function is designed for use with an association graph showing the pairwise | |
#' dependencies among categorical variables in a loglinear model for frequencies | |
#' fit using \code{\link[MASS]{loglm}} or \code{\link[stats]{glm}} in a poisson family. | |
#' The goal is to show | |
#' an association graph diagram with edges indicating the strength of associations | |
#' between each pair of variables. | |
#' | |
#' The weight for two-way terms can be found using the deviance or LRT or AIC statistic |
This file contains 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
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head> | |
<meta charset="utf-8"> | |
<meta name="generator" content="quarto-1.0.37"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> | |
<title>Quarto: Test LaTeX newcommands in HTML doc</title> |
This file contains 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
# Demonstrate Lord's Paradox example, following Michael Clarke | |
# https://m-clark.github.io/docs/lord/index.html | |
library(ggplot2) | |
library(dplyr) | |
#' ## Data example: Initial and final weight for boys & girls | |
#' | |
#' Make a plot showing the distribution of gain scores perpendicular to the line of slope = 1 | |
#' |
This file contains 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
@comment{Physical analogs for statistical models} | |
@article{GainesPalphrey:1932, | |
ISSN = {00368075, 10959203}, | |
URL = {http://www.jstor.org/stable/1658643}, | |
author = {W. L. Gaines and J. R. Palfrey}, | |
journal = {Science}, | |
number = {1977}, | |
pages = {472--474}, | |
publisher = {American Association for the Advancement of Science}, |
NewerOlder