Skip to content

Instantly share code, notes, and snippets.

View jkaupp's full-sized avatar

Jake Kaupp jkaupp

View GitHub Profile
@rafapereirabr
rafapereirabr / Flow Map in R
Last active February 24, 2024 00:46
Create Flow Map in R using ggplot2
## This gist shows how to create Flow Maps in R using ggplot2.
## source: This is based on different bits of code from other with amazing R skills:
@ceng_l : http://web.stanford.edu/~cengel/cgi-bin/anthrospace/great-circles-on-a-recentered-worldmap-in-ggplot
@3wen : http://egallic.fr/maps-with-r/
@spatialanalysis : http://spatialanalysis.co.uk/2012/06/mapping-worlds-biggest-airlines/
@freakonometrics : http://freakonometrics.hypotheses.org/48184
# Libraries
@timelyportfolio
timelyportfolio / README.md
Last active December 27, 2016 15:53
R + d3.js for interpolating colors in LAB

I spotted this blog post about interpolating colors in LAB with d3.js. Since I think the scales package in R doesn't get the attention it deserves, I wanted to replicate the example in R.

in R with scales

# do d3 interpolateLab in R with scales
# https://translate.google.com/translate?hl=en&sl=ja&tl=en&u=http%3A%2F%2Fblog.aagata.ciao.jp%2F%3Feid%3D116

library(scales)
plot(
---
title: "ggiraph with bar chart tooltips"
author: "hrbrmstr"
date: "`r Sys.Date()`"
output:
html_document:
css: ggiraphe.css
---
The full `Rmd` and `css` files for this are in <a target=_blank href="https://gist.github.com/hrbrmstr/5ee3123f7161580d4cdf">this gist</a>.
stat_smooth_func <- function(mapping = NULL, data = NULL,
geom = "smooth", position = "identity",
...,
method = "auto",
formula = y ~ x,
se = TRUE,
n = 80,
span = 0.75,
fullrange = FALSE,
level = 0.95,
@marketinview
marketinview / changeNextButtonText.js
Last active July 12, 2024 18:59
Qualtrics: Change Next Button Text. This script changes the text of the Next button. Change value of newName value as needed. #qualtrics #js #jq #next #button #finish
Qualtrics.SurveyEngine.addOnReady(function() {
var newName = 'Finish'; //Update - New Next Button label
var lastLoopOnly = true; //Last loop only? Value doesn't matter to non-loops
//No changes below
if(!lastLoopOnly || "${lm://CurrentLoopNumber}" == "${lm://TotalLoops}") {
var nb = jQuery('#NextButton');
nb.val(newName);
nb.attr('title', newName);
}
});
@ramhiser
ramhiser / latlong2fips.r
Created May 6, 2014 03:35
Latitude/Longitude to FIPS Codes via the FCC's API
# FCC's Census Block Conversions API
# http://www.fcc.gov/developers/census-block-conversions-api
latlong2fips <- function(latitude, longitude) {
url <- "http://data.fcc.gov/api/block/find?format=json&latitude=%f&longitude=%f"
url <- sprintf(url, latitude, longitude)
json <- RCurl::getURL(url)
json <- RJSONIO::fromJSON(json)
as.character(json$County['FIPS'])
}
@Bouke
Bouke / gist:10454272
Last active September 22, 2025 06:27
Install FreeTDS, unixODBC and pyodbc on OS X

First, install the following libraries:

$ brew install unixodbc
$ brew install freetds --with-unixodbc

FreeTDS should already work now, without configuration:

$ tsql -S [IP or hostname] -U [username] -P [password]
locale is "en_US.UTF-8"

locale charset is "UTF-8"

---
title: "SO22524822"
author: "Thell"
date: "03/21/2014"
output: html_document
---
```{r setup}
# A killPrefix hook.
default_output_hook <- knitr::knit_hooks$get("output")
@ojessen
ojessen / passwd_prototype.R
Created January 27, 2014 20:30
Protoype password handling with hash
require(digest)
require(shiny)
ui <- basicPage(
uiOutput("register"),
actionButton("doRegister",label="Register"),
verbatimTextOutput("resultRegister"),
uiOutput("login"),

This is a short demo of how to use brew and knitr in combination with each other to get the best of the templating facilities in brew and the literate programming functions in knitr. The main idea is to write a function brew_knit

# Preprocess template using brew and then run knit on the output
brew_knit <- function(template, params, ...){
 brew::brew(template, envir = list2env(params))
 input = gsub(".Rnwe", '.Rnw', template)
 knitr::knit(input)
}