Skip to content

Instantly share code, notes, and snippets.

bigrams <- function(text){
word.vec <- strsplit(text, "\\s+")[[1]]
word.vec.length <- length(word.vec)
lapply(1:(word.vec.length-1), function(x)c(word.vec[x], word.vec[x+1]))
}
is.name <- function(bigram){
has.last.name <- tolower(bigram[2]) %in% tolower(last.names$name)
if(has.last.name){
has.first.name <- tolower(bigram[1]) %in% tolower(first.names)
isname <- has.first.name & has.last.name
}else{
isname <- has.last.name
}
return(isname)
}
@corynissen
corynissen / index.html
Created March 13, 2014 17:28
Foodbornechi Map
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.css'>
<script src='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js' type='text/javascript'></script>
<script src='https://rawgithub.com/leaflet-extras/leaflet-providers/gh-pages/leaflet-providers.js' type='text/javascript'></script>
<script src='http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js' type='text/javascript'></script>
@corynissen
corynissen / pandoc_BT.txt
Created March 24, 2014 13:50
Use pandoc to create an epub from the markdown files for the Beyond Transparency book
pandoc -S -f markdown_github -t epub -o beyondtransparency.epub --epub-cover-image cover.png part-0.md part-1-chapter-0.md part-1-chapter-01.md part-1-chapter-02.md part-1-chapter-03.md part-1-chapter-04.md part-1-chapter-05.md part-2-chapter-0.md part-2-chapter-06.md part-2-chapter-07.md part-2-chapter-08.md part-2-chapter-09.md part-2-chapter-10.md part-3-chapter-0.md part-3-chapter-11.md part-3-chapter-12.md part-3-chapter-13.md part-3-chapter-14.md part-4-chapter-0.md part-4-chapter-15.md part-4-chapter-16.md part-4-chapter-17.md part-4-chapter-18.md part-5-chapter-0.md part-5-chapter-19.md part-5-chapter-20.md part-5-chapter-21.md part-5-chapter-22.md part-5-chapter-99.md
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://code.jquery.com/jquery-1.9.1.min.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts-more.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/modules/exporting.js' type='text/javascript'></script>
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://code.jquery.com/jquery-1.9.1.min.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts-more.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/modules/exporting.js' type='text/javascript'></script>
@corynissen
corynissen / test.R
Created May 23, 2014 20:22
trying dual axis scatterplots with dates...
cs <-c("13-10-30 12:30:00", "13-10-30 12:35:00", "13-10-30 12:40:00",
"13-10-30 12:45:00", "13-10-30 12:50:00", "13-10-30 12:55:00")
x <-strptime(cs, "%y-%m-%d %H:%M:%S")
dfr <-data.frame(date=as.POSIXct(x,origin="1970-01-01"),
value1=c(1.5,1.25,.75,2.1,1.3,1.4),
value2=c(3.5,3.25,1.75,.1,6.3,2.4))
h1 <- Highcharts$new()
h1$chart(type = "scatter")
h1$chart(zoomType = "xy")
h1$xAxis(type = "datetime", data=as.POSIXct(dfr$date,origin="1970-01-01"))
@corynissen
corynissen / gist:a011eefa8bbef3d3f3c4
Created May 27, 2014 19:54
Rcharts highcharts multiple axis with date xaxis
server.R....
output$plot2 <- renderText({
date1 <- as.POSIXct(c(1400702085, 1400702385, 1400702685, 1400702985, 1400703285,
1400703585, 1400703885, 1400704185, 1400704485, 1400704785),
origin="1970-01-01")
df <- data.frame(date=date1, c1=runif(10,2, 5), c2 = runif(10, 50, 100),
c3 = runif(10, 400, 500))
df$date2 <- format(df$date, "Date.UTC(%Y,%m,%d,%H,%M)")
temp.json <- toJSONArray2(cbind(df$date2, df$c1), json = T, names = F)
@corynissen
corynissen / index.html
Created June 5, 2014 13:43
Foodbornechi Map
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.css'>
<script src='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js' type='text/javascript'></script>
<script src='https://rawgithub.com/leaflet-extras/leaflet-providers/gh-pages/leaflet-providers.js' type='text/javascript'></script>
<script src='http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js' type='text/javascript'></script>
@corynissen
corynissen / index.html
Last active August 29, 2015 14:02
Bloomington IL Bus Routes
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.css'>
<script src='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js' type='text/javascript'></script>
<script src='https://rawgithub.com/leaflet-extras/leaflet-providers/gh-pages/leaflet-providers.js' type='text/javascript'></script>
<script src='http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js' type='text/javascript'></script>