Skip to content

Instantly share code, notes, and snippets.

Avatar

evalparse xiaodaigh

View GitHub Profile
@xiaodaigh
xiaodaigh / runthis.R
Last active Dec 22, 2015
A Shiny component for Handsontable
View runthis.R
shiny::runGitHub("shinyhandsontable-example","xiaodaigh")
@xiaodaigh
xiaodaigh / server.R
Last active Oct 12, 2018
A gist of programatically changing panel tabs in Shiny
View server.R
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 / genGraphVizCode.r
Last active Dec 22, 2015
Generating GraphViz code for visualizing Shiny reactive dependencies
View genGraphVizCode.r
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")
View 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 / server.R
Created Sep 20, 2013
Beginner help on input and plotting
View server.R
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,
View color.js
$(document).delegate("#mytable",'DOMSubtreeModified','DOMNodeInserted', function(event) {
color()
});
function color(){
$('#mytable td').each(function(){
$(this).css({'background':'#CCC'});
})
}
@xiaodaigh
xiaodaigh / server.R
Created Sep 22, 2013
A simple Shiny spy to tell Shiny that the session has closed
View server.R
library(shiny)
data(pressure)
data(cars)
shinyServer(function(input, output, session) {
# Partial example
observe({
@xiaodaigh
xiaodaigh / README.md
Last active Dec 23, 2015
Shiny: Multiple selections created using one htmlOutput
View README.md

To run

shiny::runGist("6684134")

View corr.ilic.r
#
#
cor.ilic <- function(x,y) {
# tryCatch(t <- table(x,y,exclude=NULL,useNA="ifany")
# , error = function(e) {
#
# }
# )
bt <- table.p(data.frame(x=x,y=y),32)
@xiaodaigh
xiaodaigh / testparse.r
Created Sep 30, 2013
Test parset shiny
View testparse.r
#find top level expression
ancestor <- function(code.pd,id,ancestors_parent_id=0) {
this <- code.pd[code.pd$id == id,]
if(this$parent == ancestors_parent_id) return(this)
immediate_parent = code.pd[code.pd$id == this$parent,]
if(immediate_parent$parent == ancestors_parent_id)
return(immediate_parent)
return(ancestor(code.pd,immediate_parent$id,ancestors_parent_id))
}
You can’t perform that action at this time.