Skip to content

Instantly share code, notes, and snippets.

View andrewheiss's full-sized avatar
👨‍💻
#rstats-ing all the things

Andrew Heiss andrewheiss

👨‍💻
#rstats-ing all the things
View GitHub Profile
@jmclawson
jmclawson / collapse_rows.R
Last active September 4, 2023 16:19
something like "collapse rows" for gt
collapse_rows <- function(df_g, col, lookleft = TRUE){
col_num <- grep(deparse(substitute(col)), colnames(df_g$`_data`))
collapse_style <- css(visibility = "hidden",
border_top = "0px")
test_rows <- function(x) ifelse(is.na(x == lag(x)), FALSE, x == lag(x))
if(col_num > 1 & lookleft) {
col_left <- as.name(colnames(df_g$`_data`)[col_num - 1])
@richarddmorey
richarddmorey / create_covers.R
Last active May 13, 2022 11:25
Create image covers for PDFs
#' Create cover images for talks from a folder of PDFs
#'
#' Requires imagemagick to be installed and in the path for the convert command
#' @param pdf_dir Directory containing PDF files of papers
#' @param img_dir Directory to output all the image files
#' @param crop_height How big to make the cropped images, relative to full page
#' @param fade_height How much of the image to fade to transparent at the bottom
#' @param density resolution for PNG images
#'
create_covers = function(pdf_dir, img_dir, crop_height = .5, fade_height = .25, density = 300){
## Start with the code in https://github.com/kjhealy/lexis_surface/blob/master/lexis.r
## At the bottom, the `fra_surface` object is done in 3D with the `plotly` library. We can
## also do it with `rayshade`:
library(rayshader)
## rayshade wants the axes a little differently from plotly
## but like plotly it wants a matrix.
fra_surf <- fra_surf[c(1:201),c(100:1)]
#!/bin/bash
TODAY=`date +%Y-%m-%d`
TODAY_MD=`date +%B\ %d,\ %Y`
YEAR=`date +%Y`
PACKAGENAME=$1
##
## CHANGE ME!!!
@leeper
leeper / shrugp.R
Created November 21, 2016 12:01
Transform p-values into "shruggies" of confidence-specific shrugginess
shrugp <- function(p) {
out <- symnum(p, cutpoints = c(0, 0.001, 0.01, 0.05, 0.10, 1.00),
symbols = c("(ツ)", "¯\\(ツ)/¯", "¯\\_(ツ)_/¯", "¯\\___(ツ)___/¯", "¯\\____(ツ)____/¯"))
as.character(out)
}
pvals <- c(0.09, 0.03, 0.002, 0.000001)
shrugp(pvals)
## [1] "¯\\___(ツ)___/¯" "¯\\_(ツ)_/¯" "¯\\(ツ)/¯" "(ツ)"
@pandafulmanda
pandafulmanda / Python3 Virtualenv Setup.md
Last active March 12, 2024 15:59 — forked from akszydelko/Python3 Virtualenv Setup.md
Setting up and using Python3 Virtualenv on Mac

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3
@andrewheiss
andrewheiss / original_bom_chapters.csv
Created March 16, 2016 13:08
Original Book of Mormon chapters
Book Original chapter Modern reference
1 Nephi I 1–5
II 6–9
III 10–14
IV 15
V 16–19:21
VI 19:22–21
VII 22
2 Nephi I 1–2
II 3
@rubenarslan
rubenarslan / amigoingmad.R
Last active April 13, 2016 13:39
am I going mad or has some package overwritten dplyr's functions again?
#' Function is also in this package: https://github.com/rubenarslan/formr
#' It's easy to attach packages that overwrite functions from other packages. Especially dplyr has a lot of conflicts
#' with base packages, MASS and plyr. Because some of these conflicts do not always lead to error messages, sometimes
#' just incorrect behaviour, this function exists. Don't trust your faulty memory, just check whether dplyr's (or any other
#' package's) functions are 'on top' if you so desire.
#'
#' @param fix defaults to true. Detaches the desired package (without unloading) and loads it again. Won't work for base packages and can't overwrite functions that you defined yourself.
#' @param package the package you want to be on top (loaded last), defaults to dplyr
#' @param iteration for internal use only, if set to 0 the function will call itself to check that it worked, if set to 1, it won't.
#' @export
@mdlincoln
mdlincoln / rstudio-cc.yml
Last active August 9, 2022 11:46
cloud-config script to setup Rstudio server and Shiny server on Ubuntu 14.04 on Digital Ocean
#cloud-config
# In order to access RStudio server via the web interface, you must log on with
# a user account that allows password access. This script does not add that user
# by default. You may either ssh as root into the server and `adduser` as
# normal, or script a user addition here:
# users:
# - name: # username #
# lock-passwd: false # allow login with password
@jefferys
jefferys / roxygen2MultiFunctionDocumentation.gist.R
Created June 21, 2015 17:29
R function documentation with roxygen2 - multiple functions
#===================================================
# Demo multi-function roxygen2 - three ways to do it
#===================================================
# This shows how things do work, including wierd corner cases, not
# how they should be done. Most of the information comes from
# http://r-pkgs.had.co.nz/man.html
#====================================================
# Demo multi-function roxygen2 page using @describeIn