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(shiny) | |
runApp(list( | |
ui = fluidPage(downloadButton('foo')), | |
server = function(input, output) { | |
plotInput = reactive({ | |
plot(1:10) | |
}) | |
output$foo = downloadHandler( | |
filename = 'test.pdf', | |
content = function(file) { |
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(shiny) | |
shinyServer( | |
function(input, output) { | |
plotInput <- reactive({ | |
if(input$returnpdf){ | |
pdf("plot.pdf", width=as.numeric(input$w), height=as.numeric(input$h)) | |
plot(rnorm(sample(100:1000,1))) | |
dev.off() | |
} |
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
require(shiny) | |
# inbuilt dataset | |
diamonds = ggplot2::diamonds[,c(1,5,7)] | |
# csv datasets to input via front-end | |
for(i in 1:3){ | |
dat <- diamonds[sample(1:nrow(diamonds), 200),] | |
write.table(dat, paste0('dat',i,'.csv'), sep=',',row.names=F, col.names=T) | |
} |
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
<?php | |
/** | |
* Website: http://sourceforge.net/projects/simplehtmldom/ | |
* Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/) | |
* Contributions by: | |
* Yousuke Kumakura (Attribute filters) | |
* Vadim Voituk (Negative indexes supports of "find" method) | |
* Antcs (Constructor with automatically load contents either text or file/url) | |
* | |
* all affected sections have comments starting with "PaperG" |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Comma-URL test</title> | |
</head> | |
<body> | |
<h1>Comma-URL test</h1> | |
<p>Let's try and parse: http://en.m.wikipedia.org/wiki/National_Register_of_Historic_Places_listings_in_San_Francisco,_California</p> | |
<?php |
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
require(ggplot2); require(tidyr); require(dplyr) | |
dat = data.frame(grp=letters[1:3], very_bad=c(4,2,1), bad=c(3,4,2), good=c(2,3,4), very_good=c(1,1,3)) | |
(d = dat %>% tidyr::gather(rating, value, very_bad:very_good) %>% | |
mutate(rating = ordered(rating, levels=c('very_bad','bad','good','very_good')))) | |
ggplot() + | |
geom_bar(data = subset(d, rating %in% c('very_bad','bad')),aes(grp, -value, fill=rating), position="stack", stat="identity") + | |
geom_bar(data = subset(d, !rating %in% c('very_bad','bad')), aes(grp, value, fill=rating), position="stack", stat="identity") + | |
scale_fill_manual(values=colorRampPalette(c('red','grey','green'))(4)) + |
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
# *** PACKAGE IS CURRENTLY UNDER DEVELOPMENT SO THIS CODE MAY NOT WORK *** | |
# this doesn't do the iwanthue tool justice it just shows the flow | |
# checkout http://tools.medialab.sciences-po.fr/iwanthue/ for detail | |
require(devtools) | |
install_github("hoesler/rwantshue") | |
require(rwantshue) | |
scheme <- iwanthue() |
We can't make this file beautiful and searchable because it's too large.
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
date,day,city,desc,maxtemp,mintemp,wind_dir,wind_speed,visibility,pressure,humidity,uv_risk,pollution | |
28/06/2014,0,London,Heavy Rain,20,12,East South Easterly,6mph,Poor,1010mb,66%,5,Low | |
28/06/2014,1,London,Sunny Intervals,20,12,North North Westerly,10mph,Good,1013mb,45%,6,Low | |
28/06/2014,2,London,Sunny Intervals,21,13,South Easterly,5mph,Very Good,1018mb,45%,6,Low | |
28/06/2014,0,Manchester,Light Rain,16,11,North Easterly,6mph,Moderate,1012mb,82%,3,Low | |
28/06/2014,1,Manchester,Sunny Intervals,18,10,North North Westerly,7mph,Very Good,1014mb,48%,6,Low | |
28/06/2014,2,Manchester,Sunny Intervals,19,12,South South Westerly,3mph,Very Good,1017mb,52%,6,Low | |
28/06/2014,0,Cardiff,Thundery Shower,18,13,North North Easterly,3mph,Very Good,1009mb,64%,5,Low | |
28/06/2014,1,Cardiff,Light Rain,18,11,South Westerly,6mph,Good,1014mb,67%,6,Low | |
28/06/2014,2,Cardiff,Light Cloud,19,13,South South Easterly,7mph,Very Good,1016mb,57%,6,Low |
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
// When using HOTOSM (e.g. http://tasks.hotosm.org/project/1513), run this | |
// in the browser's console and the project bounding box will be returned | |
(function (){ | |
var xmin = 360; var xmax = 0; var ymin = 90; var ymax = -90; | |
for(var i=0; i<geometry.coordinates.length; i++){ | |
var set = geometry.coordinates[i][0]; | |
for(var j=0; j<set.length; j++){ | |
var x = set[j][0]; | |
var y = set[j][1]; | |
if(x > xmax) xmax = x; |
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
# ref: http://stackoverflow.com/questions/31745894/get-aspect-ratio-for-lat-long-plots/31746542#31746542 | |
# requires ggplot2 | |
map_aspect = function(x, y) { | |
x.center <- sum(range(x)) / 2 | |
y.center <- sum(range(y)) / 2 | |
x.dist <- ggplot2:::dist_central_angle(x.center + c(-0.5, 0.5), rep(y.center, 2)) | |
y.dist <- ggplot2:::dist_central_angle(rep(x.center, 2), y.center + c(-0.5, 0.5)) | |
y.dist / x.dist | |
} |