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(sp) | |
| library(RColorBrewer) | |
| # get spatial data for Germany on county level | |
| con <- url("http://gadm.org/data/rda/DEU_adm3.RData") | |
| print(load(con)) | |
| close(con) | |
| # plot Germany with random colors | |
| col = rainbow(length(levels(gadm$NAME_3))) |
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
| ### DATA PREP ### | |
| # loading the unemployment data | |
| unempl <- read.delim2(file="./data/data_germany_unemployment_by_ | |
| county.txt", header = TRUE, sep = "\t", | |
| dec=",", stringsAsFactors=F) | |
| # due to Mac OS encoding, otherwise not needed | |
| gadm_names <- iconv(gadm$NAME_3, "ISO_8859-2", "UTF-8") | |
| # fuzzy matching of data: quick & dirty |
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, session) { | |
| output$results <- renderPrint({ | |
| input$mydata | |
| }) | |
| }) |
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, session) { | |
| output$results <- renderPrint({ | |
| input$mydata | |
| }) | |
| # observer if value of the data sent from the client changes | |
| # if yes generate a new random color and send it back to |
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
| // Execute function body when the HTML document is ready | |
| $(document).ready(function() { | |
| // javascript code to send data to shiny server | |
| document.getElementById("mydiv").onclick = function() { | |
| var number = Math.random(); | |
| Shiny.onInputChange("mydata", number); | |
| }; | |
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(shinyIncubator) | |
| shinyServer(function(input, output, session) { | |
| output$out2 <- renderPrint({ | |
| "output 2" | |
| }) | |
| output$plot <- renderPlot({ |
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
| shinyServer(function(input, output, session) { | |
| observe({ | |
| input$btn | |
| session$sendCustomMessage(type = "resetFileInputHandler", "file1") | |
| }) | |
| }) |
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
| change_tex_delimiters <- function(x) | |
| { | |
| # replace latex equation delimiters ($$) if present | |
| eq <- which(x == "$$") # find positions of equations | |
| if (length(eq) > 0) { | |
| eq.begin <- eq[c(T,F)] | |
| eq.end <- eq[c(F,T)] | |
| for (i in eq.begin) | |
| x[[i]] <- "$latex \\displaystyle" | |
| for (i in eq.end) |
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(colorspace) | |
| polar2cart <- function(r, theta) # polar to cartesian coords | |
| { | |
| rad <- theta * pi /180 | |
| cbind(x = r*cos(rad), | |
| y = r*sin(rad)) | |
| } | |
| h <- seq(0, 360, len=150) # hue values |
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
| node_barplot2 <- function(obj, | |
| col = "black", | |
| fill = NULL, | |
| beside = NULL, | |
| ymax = NULL, | |
| ylines = NULL, | |
| widths = 1, | |
| gap = NULL, | |
| reverse = NULL, | |
| id = TRUE, |
OlderNewer