Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Multi-tasking

Martin Monkman MonkmanMH

🎯
Multi-tasking
View GitHub Profile
@MonkmanMH
MonkmanMH / transform_data_solutions.Rmd
Created Nov 4, 2019
Answer key for tidyverse transform data exercises
View transform_data_solutions.Rmd
---
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 Jul 12, 2020
Shows us why visualizing residuals from a model is important
View orly-owl-residuals
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
brown bear brown bear
View brown_bear.R
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 Oct 16, 2019
Supreme Annotations - moar splainin here: http://rud.is/b/2016/03/16/supreme-annotations/ - NOTE: this requires the github version of ggplot2
@wesrice
wesrice / sabermetrics_batting.sql
Last active Sep 4, 2018
SQL Views for Sabermetrics using Lahman's Baseball Database
View sabermetrics_batting.sql
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,
@jennybc
jennybc / twee-demo.Rmd
Last active Oct 15, 2020
twee(): emulating the tree directory listing command
View twee-demo.Rmd
---
title: "twee demo"
author: "Jenny Bryan"
date: "17 August, 2014"
output:
html_document:
toc: TRUE
keep_md: TRUE
---
@shivaas
shivaas / US Bank holidays
Last active Oct 5, 2020
CSV for all US bank holidays till 2020. First row is the header. Dates are MYSQL format.
View US Bank holidays
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
@protolif
protolif / picard-facepalm-ascii.txt
Created May 22, 2012
Captain Picard Facepalm ASCII
View picard-facepalm-ascii.txt
............................................________
....................................,.-'"...................``~.,
.............................,.-"..................................."-.,
.........................,/...............................................":,
.....................,?......................................................,
.................../...........................................................,}
................./......................................................,:`^`..}
.............../...................................................,:"........./
..............?.....__.........................................:`.........../
............./__.(....."~-,_..............................,:`........../
@jeromyanglim
jeromyanglim / example-r-markdown.rmd
Created May 17, 2012
Example of using R Markdown
View example-r-markdown.rmd
This post examines the features of [R Markdown](http://www.rstudio.org/docs/authoring/using_markdown)
using [knitr](http://yihui.name/knitr/) in Rstudio 0.96.
This combination of tools provides an exciting improvement in usability for
[reproducible analysis](http://stats.stackexchange.com/a/15006/183).
Specifically, this post
(1) discusses getting started with R Markdown and `knitr` in Rstudio 0.96;
(2) provides a basic example of producing console output and plots using R Markdown;
(3) highlights several code chunk options such as caching and controlling how input and output is displayed;
(4) demonstrates use of standard Markdown notation as well as the extended features of formulas and tables; and
(5) discusses the implications of R Markdown.
You can’t perform that action at this time.