Skip to content

Instantly share code, notes, and snippets.

View maptracker's full-sized avatar

Charles Tilford maptracker

  • Work-related, non-proprietary coding
View GitHub Profile
@maptracker
maptracker / WorldHeat.r
Last active November 14, 2017 17:42 — forked from cavedave/WorldHeat.r
Heatmap of world Temperature in r package for ggplot2
### FORKED FROM: https://gist.github.com/cavedave/8ff22e94c882e9f6be933f99f2ae0b50
## Charles changed:
## Absolute URLs to library/data (rather than local files)
## Raster rather than tiles (didn't like the grid lines)
## Gradient from red (hot) to blue (cold) with black at zero (no change from average)
## Removed year filter
## Defined title and breaks via automatic extraction of dates from data
## Scaled down plot to be more friendly for Gist
## Took out unused libraries
# Fork of Scott's coin flip simulation
# https://gist.github.com/maptracker/e34a8596a9c2a7f261d6b892e5df42c5
flipCoin <- function( n = 50, pvals = 0.5, nosim = 100, file = NULL ) {
coverage <- lapply(pvals, function(p) {
phats <- (rbinom(nosim, prob = p, size = n) + 2)/(n + 4)
ll <- phats - qnorm(0.975) * sqrt(phats * (1 - phats)/n)
ul <- phats + qnorm(0.975) * sqrt(phats * (1 - phats)/n)
cbind(lower = ll, upper = ul)
})[[1]] # De-listify