This file contains hidden or 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(maptools) | |
| require(fields) | |
| require(ggplot2) | |
| require(stringr) | |
| bng = "+init=epsg:27700" | |
| workdir = '[change to working directory path]' | |
| setwd(workdir) | |
| R.utils::mkdirs('wz') |
This file contains hidden or 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
| # read in csv file with headings labelled 'e' and 'n' and output latlons | |
| # call script by command-line: 'RScript bng_to_latlon.R {bng_filename.csv}' | |
| require(rgdal) | |
| args=(commandArgs(TRUE)) | |
| datain = read.csv(args[1]) | |
| bng = datain | |
| coordinates(bng) = ~ e + n | |
| bng@proj4string = CRS("+init=epsg:27700") | |
| latlon = spTransform(bng, CRS("+proj=longlat +datum=WGS84")) |
This file contains hidden or 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) | |
| library(rCharts) | |
| library(ggplot2) | |
| data(uspop2000, package = 'leaflet') | |
| base_df <- head(uspop2000[which(uspop2000$State == "AL"), ]) | |
| shinyServer(function(input, output){ | |
| output$myChart <- renderMap({ |
This file contains hidden or 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(alluvial) | |
| require(reshape2) | |
| d <- read.table(text="Class,1991,2003,2005,2009,2011,2013 | |
| 1,818,604,601,570,563,556 | |
| 2,183,147,145,143,142,150 | |
| 3,40,55,55,55,55,50 | |
| 4,48,70,81,76,85,99 | |
| 5,126,140,142,148,155,153 | |
| 6,396,566,568,566,525,508 |
This file contains hidden or 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) | |
| library(ggplot2) | |
| shinyServer(function(input, output) { | |
| datasetInput <- reactive({ | |
| switch(input$dataset, | |
| "rock" = rock, | |
| "pressure" = pressure, | |
| "cars" = cars) | |
| }) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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)) + |
OlderNewer