Skip to content

Instantly share code, notes, and snippets.

View MonkmanMH's full-sized avatar
🎯
Multi-tasking

Martin Monkman MonkmanMH

🎯
Multi-tasking
View GitHub Profile
@tylermorganwall
tylermorganwall / humanity_globe.R
Created August 17, 2021 14:37
3D Humanity Globe
library(rayshader)
library(rayrender)
popdata = raster::raster("gpw_v4_population_density_rev11_2020_15_min.tif")
population_mat = rayshader:::flipud(raster_to_matrix(popdata))
above1 = population_mat > 1
above5 = population_mat > 5
above10 = population_mat > 10
@z3tt
z3tt / github.R
Last active November 6, 2024 02:59
Configure GitHub for Rstudio
#### 1. Sign up at GitHub.com ################################################
## If you do not have a GitHub account, sign up here:
## https://github.com/join
# ----------------------------------------------------------------------------
#### 2. Install git ##########################################################
## If you do not have git installed, please do so:
@MonkmanMH
MonkmanMH / transform_data_solutions.Rmd
Created November 4, 2019 03:34
Answer key for tidyverse transform data exercises
---
title: "Transform Data"
subtitle: "hands-on examples, with answers"
output: html_notebook
---
<!-- This file by Charlotte Wickham (with some modifications by Martin Monkman) is licensed under a Creative Commons Attribution 4.0 International License, adapted from the orignal work at https://github.com/rstudio/master-the-tidyverse by RStudio and https://github.com/cwickham/data-science-in-tidyverse-solutions. -->
```{r setup}
library(tidyverse)
@apreshill
apreshill / orly-owl-residuals
Last active July 12, 2020 21:57
Shows us why visualizing residuals from a model is important
library(broom)
library(ggplot2)
# read in the data
# others available here: http://www4.stat.ncsu.edu/~stefanski/NSF_Supported/Hidden_Images/stat_res_plots.html
owl <- read.table("http://www4.stat.ncsu.edu/~stefanski/NSF_Supported/Hidden_Images/orly_owl_files/orly_owl_Lin_4p_5_flat.txt",
header = FALSE)
# fit the linear model
fit <- lm(V1 ~ . - 1, data = owl)
@jimhester
jimhester / brown_bear.R
Last active May 19, 2017 00:34
brown bear brown bear
x <- c("Brown bear", "Red bird", "Yellow duck", "Blue horse", "Green frog", "Purple Cat", "Goldfish", "Teacher")
txt <- capture.output(cat(
sprintf("%s, %s, what do you see?\n I see a %s looking at me.\n", head(x, -1), head(x, -1), tail(x, -1)),
sprintf("Teacher, Teacher what do you see\n I see Children looking at me.\nChildren Children what do you see?\n We see a %s and a Teacher looking at us, that's what we see.",
paste0(collapse = ", ", head(x, -1))), sep = ""))
txt
#> Brown bear, Brown bear, what do you see?
#> I see a Red bird looking at me.
#> Red bird, Red bird, what do you see?
#> I see a Yellow duck looking at me.
@hrbrmstr
hrbrmstr / orig.png
Last active July 16, 2023 06:43
Supreme Annotations - moar splainin here: http://rud.is/b/2016/03/16/supreme-annotations/ - NOTE: this requires the github version of ggplot2
orig.png
@wesrice
wesrice / sabermetrics_batting.sql
Last active August 22, 2022 18:40
SQL Views for Sabermetrics using Lahman's Baseball Database
CREATE OR REPLACE VIEW sabermetrics_batting AS
SELECT
batting.*,
-- PA - Plate Appearances
(batting.AB + batting.BB + batting.HBP + batting.SF + batting.SH) as PA,
-- BB% - Walk Percentage (http://www.fangraphs.com/library/offense/rate-stats/)
round((batting.BB / (batting.AB + batting.BB + batting.HBP + batting.SF + batting.SH)), 3) as BBpct,
@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
@jennybc
jennybc / twee-demo.Rmd
Last active August 14, 2022 21:50
twee(): emulating the tree directory listing command
---
title: "twee demo"
author: "Jenny Bryan"
date: "17 August, 2014"
output:
html_document:
toc: TRUE
keep_md: TRUE
---
@shivaas
shivaas / US Bank holidays (up to 2020)
Last active February 27, 2023 04:16
CSV for all US bank holidays till 2020. First row is the header. Dates are MYSQL format.
1,2012-01-02,New Year Day
2,2012-01-16,Martin Luther King Jr. Day
3,2012-02-20,Presidents Day (Washingtons Birthday)
4,2012-05-28,Memorial Day
5,2012-07-04,Independence Day
6,2012-09-03,Labor Day
7,2012-10-08,Columbus Day
8,2012-11-12,Veterans Day
9,2012-11-22,Thanksgiving Day
10,2012-12-25,Christmas Day