Skip to content

Instantly share code, notes, and snippets.

View xiaodaigh's full-sized avatar

evalparse xiaodaigh

View GitHub Profile
@xiaodaigh
xiaodaigh / server.R
Created September 20, 2013 02:20
Beginner help on input and plotting
library(shiny)
#tu<-read.csv(file="tu.csv", header = TRUE, sep = ",")
#attach(tu)
tu <- data.frame(id=rnorm(1000),size=rnorm(1000),months=rnorm(1000))
shinyServer(function(input, output) {
it<- reactive({
print(input$tu)
switch(input$tu,
"id" = tu$id,
@xiaodaigh
xiaodaigh / dataset.txt
Last active December 22, 2015 19:29 — forked from jcheng5/dataset.txt
item1,item2,item3,item4,item5,item6,item7,item8,item9,item10
1,1,,,1,1,,,,
,,1,1,,,1,1,,
1,,,,1,,,,1,1
,1,,1,1,,1,,1,
1,1,1,1,1,1,,,,1
,1,,,,,1,,,
,,1,1,1,1,,1,,
1,,,1,,,,1,,1
,,1,1,1,,,,1,1
@xiaodaigh
xiaodaigh / genGraphVizCode.r
Last active December 22, 2015 08:39
Generating GraphViz code for visualizing Shiny reactive dependencies
d <- parse("server stripped bare.R")
dc <- as.character(d)
reactives <- NULL
# find reactive sources
for(t in dc) {
if( grepl("reactive(.*)$",t)) { #if it is reactive
g <- gregexpr("^[A-Za-z0-9._]*",t)
p <- as.numeric(g[[1]])
l <- attr(g[[1]],"match.length")
@xiaodaigh
xiaodaigh / server.R
Last active June 9, 2021 22:47
A gist of programatically changing panel tabs in Shiny
library(shiny)
# Define server logic for random distribution application
shinyServer(function(input, output) {
# Reactive expression to generate the requested distribution. This is
# called whenever the inputs change. The renderers defined
# below then all use the value computed from this expression
data <- reactive({
dist <- switch(input$dist,
@xiaodaigh
xiaodaigh / runthis.R
Last active December 22, 2015 07:49
A Shiny component for Handsontable
shiny::runGitHub("shinyhandsontable-example","xiaodaigh")