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 October 12, 2013 06:16
Shiny R - Re-initialise reactive values
library(shiny)
shinyServer(function(input,output){
reval <- reactiveValues(a= 1,b=2,dummy= rnorm(1))
observe({
if(input$hello == 0) return()
random.number <- rnorm(1)
reval$dummy <- random.number
b <- reval$b
@xiaodaigh
xiaodaigh / server.R
Last active August 18, 2022 17:45
Shiny: Disable Button
library(shiny)
disableActionButton <- function(id,session) {
session$sendCustomMessage(type="jsCode",
list(code= paste("$('#",id,"').prop('disabled',true)"
,sep="")))
}
shinyServer(function(input, output,session) {
@xiaodaigh
xiaodaigh / server.R
Created October 1, 2013 16:20
Shiny output doesn't run if no input?
library(shiny)
library(shinyIncubator)
options(shiny.reactlog=TRUE);
shinyServer(function(input, output,session) {
output$test <- renderPlot({
input$meh
print("wassup")
withProgress(session, min=1, max=15, {
?showReactLog
options(shiny.reactlog=TRUE);
session$sendCustomMessage(type="jsCode",
list(code= paste("$('#",id,"').prop('disabled',true)"
,sep="")))
tags$head(tags$script(HTML('
Shiny.addCustomMessageHandler("jsCode",
@xiaodaigh
xiaodaigh / server.R
Last active December 24, 2015 08:49 — forked from tcash21/server.R
require(shiny)
require(rCharts)
inputChoices <- c("A", "B", "C", "D")
shinyServer(function(input, output, session){
input2Choices <- reactive({
inputChoices[-grep(input$input1, inputChoices)]
})
@xiaodaigh
xiaodaigh / testparse.r
Created September 30, 2013 06:29
Test parset shiny
#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))
}
@xiaodaigh
xiaodaigh / corr.ilic.r
Created September 30, 2013 06:28
pamp gini
#
#
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 / README.md
Last active December 23, 2015 19:39
Shiny: Multiple selections created using one htmlOutput

To run

shiny::runGist("6684134")

@xiaodaigh
xiaodaigh / server.R
Created September 22, 2013 18:49
A simple Shiny spy to tell Shiny that the session has closed
library(shiny)
data(pressure)
data(cars)
shinyServer(function(input, output, session) {
# Partial example
observe({
@xiaodaigh
xiaodaigh / color.js
Created September 22, 2013 17:56 — forked from anonymous/color.js
$(document).delegate("#mytable",'DOMSubtreeModified','DOMNodeInserted', function(event) {
color()
});
function color(){
$('#mytable td').each(function(){
$(this).css({'background':'#CCC'});
})
}