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
tell_it_like_it_is <- function(){ | |
message <- paste0( | |
sprintf(cow, sample(mess, 1)), | |
"\n\n\n\n" | |
) | |
cat(message) | |
} | |
cow <- "\n ---------------- \n%s! \n ----------------- \n \\ ^__^ \n \\ (oo)\\ ________ \n (__)\\ )\\ /\\ \n ||------w|\n || ||" |
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
## Originally taken from: https://juliasilge.github.io/ibm-ai-day/slides.html#1 | |
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load(tidyverse, gutenbergr) | |
## Scrape known books | |
titles <- c( | |
"Twenty Thousand Leagues under the Sea", | |
"The War of the Worlds", | |
"Pride and Prejudice", |
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
if (!require("pacman")) install.packages("pacman"); library(pacman) | |
p_load(tidyverse, openxlsx, magrittr, pander, numform) | |
## make an environment to store everything | |
my_tables <- new.env() | |
## basic boiler plate chunk to add | |
## %T>% |
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
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load(ggimage) | |
presidential_icons <- data.frame( | |
x = c(15, 30), | |
y = c(2.5, 4.5), | |
name = c('trump', 'obama'), | |
image = c( | |
'http://www.stickpng.com/assets/images/5841c17aa6515b1e0ad75aa1.png', |
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
library(tidyverse) | |
as.data.frame(M, stringsAsFactors = FALSE) %>% | |
rownames_to_column('id') %>% | |
mutate( | |
id = gsub('SuperSMART_', 'S', id), | |
id = gsub('(^S)(\\d{2})(_)', '\\10\\2\\3', id, perl = TRUE) | |
) %>% | |
separate(id, into = c('S', 'R', 'p'), sep = '_', remove = FALSE) %>% | |
mutate(., group = group_indices(., S)) |
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
https://twitter.com/lenkiefer/status/1010880251788955648 |
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
percentile1 <- function(x) ecdf(x)(x) | |
percentile2 <- function(x) rank(x)/length(x) | |
library(tidyverse) | |
out <- data_frame( | |
x = rnorm(100000), | |
ecdf = ecdf(x)(x), | |
rank_len = rank(x)/length(x), | |
same = near(ecdf, rank_len) |
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
ffmpeg -i intro_to_r.mp4 -filter_complex "[0:v]setpts=0.6666667*PTS[v];[0:a]atempo=1.5[a]" -map "[v]" -map "[a]" intro_to_r2.mp4 | |
## r code | |
## atempo=1.25 | |
## setpts=1/atempo | |
ffmpeg -i 04_viz_grammar_and_theory.mp4 -filter_complex "[0:v]setpts=0.8*PTS[v];[0:a]atempo=1.25[a]" -map "[v]" -map "[a]" 04_viz_grammar_and_theory2.mp4 |
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
## My understanding of a qqplot was it was the sorted values for a variable on the | |
## y against the theoretical values from a normal (or whatever distribution) | |
## distribution on the x. We can get the y values from our sample and the x values | |
## from looking up the p value in a given distribution and getting the | |
## corresponding nromal value. Now to get the p value I thought we divide the 1 | |
## through length of the sample by n + 1. I have never actually tried to do this | |
## and used qqplot or the same geom_qq from ggplot. But today I tried to make the | |
## qqplot by hand and I don't get the same scale for the theoretical values and am | |
## unsure why. The points look the same but the scale is different. Why? |
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
<!-- http://www.brucelawson.co.uk/2010/a-minimal-html5-document/ --> | |
<!doctype html> | |
<html lang=en> | |
<head> | |
<meta charset=utf-8> | |
<title>blah</title> | |
</head> | |
<body> |