All the code for the Medium Post
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
--- | |
output: html_document | |
--- | |
```{r, fig.show='hide', include=FALSE} | |
library(colformat) | |
x1 <- c("Using R Markdown and the colformats package we can put a sparkbar in | |
line with the text using inline R code, like this `` `r '\x60r spark_bar(x)\x60'` ``. | |
Here's a sparkbar showing a histogram of the number of characters | |
in each word in this text: `r spark_bar(x2)`. And here is a sparkbar |
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
airline | voluntary_denied | involuntary_denied | enplaned_ct | involuntary_db_per_10k | year | |
---|---|---|---|---|---|---|
Hawaiian Airlines | 326 | 49 | 10824495 | 0.05 | 2016 | |
Delta Air Lines | 129825 | 1238 | 129281098 | 0.1 | 2016 | |
Virgin America | 2375 | 94 | 7945329 | 0.12 | 2016 | |
Alaska Airlines | 6806 | 931 | 23390900 | 0.4 | 2016 | |
United Airlines | 62895 | 3765 | 86836527 | 0.43 | 2016 | |
Spirit Airlines | 10444 | 1117 | 19418650 | 0.58 | 2016 | |
Frontier Airlines | 2096 | 851 | 14666332 | 0.58 | 2016 | |
American Airlines | 54259 | 8312 | 130894653 | 0.64 | 2016 | |
Jetblue Airways | 1705 | 3176 | 34710003 | 0.92 | 2016 |
Access this Gist via this shortened URL: https://git.io/vPj49
If anything changes, with regards to the material covered in this course, this will be the first place I share updates.
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
#This is inspired by this piral animation of the same dataset | |
#http://www.climate-lab-book.ac.uk/2016/spiralling-global-temperatures/ | |
#and this R code to produce the animation | |
#https://gist.github.com/jebyrnes/b34930da0052a86f5ffe254ce9900357 | |
# It also uses elements of this http://www.r-bloggers.com/making-faceted-heatmaps-with-ggplot2/ | |
# and this https://rpubs.com/bradleyboehmke/weather_graphic graphic | |
library(dplyr) | |
library(tidyr) | |
library(ggplot2) |
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
library(idbr) | |
library(dplyr) | |
library(ggplot2) | |
library(tidyr) | |
library(countrycode) | |
library(gganimate) | |
library(tweenr) | |
ctrys <- countrycode(c('South Africa', 'Botswana', 'Lesotho', 'Namibia', 'Zimbabwe', 'Swaziland'), | |
'country.name', 'fips104') |
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
library(rvest) | |
library(urltools) | |
library(rmarkdown) | |
# Some Rmd template setup ----------------------------------------------------------- | |
preamble <- '--- | |
title: "CRAN Mirrors Certificate Expiration Dashboard (Days left from %s)" | |
output: | |
flexdashboard::flex_dashboard: |
Nowhere near as spectacular as the Upshot/New York Times 3d yield curve by Amanda Cox and Gregor Aisch, but not bad at all for a couple of lines of R
code with the plotly
htmlwidget.
library(plotly)
library(dplyr)
library(tidyr)
library(purrr)
library(quantmod)
library(magrittr)
You'll need to make 2 plots and use grid.arrange
if you want more uniform spacing in 8.1 and 8.2. You can add a fill to strip.background
to extend the background colors and rotate the text with strip.text
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
## http://polygraph.cool/films/ | |
## https://github.com/matthewfdaniels/scripts | |
x <- "https://raw.githubusercontent.com/matthewfdaniels/scripts/master/data/character_list5.csv" | |
characters <- read.csv(x, na.strings = c("NULL", "?"), | |
fileEncoding = "ISO-8859-1", stringsAsFactors = FALSE) | |
## some ages are clearly (negative) birth years ... oops | |
characters$age[!is.na(characters$age) & characters$age < 0] <- NA | |
characters$age[!is.na(characters$age) & characters$age > 105] <- NA |
NewerOlder