d3.js - Shiny R : D3HeatMap triggered after click button - ReactiveEvent or ObserveEvent -


i'd trigger heatmap display after has clicked button. initially, heapmap generated each time interacting wigdet. example, if changed color, heapmap regenerated directly. want first select color , click button generate heapmap picture. don't succeed make works reactiveevent or observeevent.

server.r

library(shiny) library(d3heatmap) library(shinythemes) require(rcolorbrewer) library(dplyr)  shinyserver(  function(input, output,session) {   output$heatmap<- renderd3heatmap({      loading_effect()       infile <-input$file1     if (is.null(input$file1)) return(null)      nba_players <- read.csv(infile$datapath, sep=";",row.names=1,na.strings = c("undef"))      rownamesfiltered <- grep(paste0("^",input$gene,"-.*$", collapse = null),rownames(nba_players),ignore.case = true,value = true)       data_filtered =  filter(nba_players, grepl(paste0("^",input$gene, collapse = null),rownames(nba_players) ))      row.names(data_filtered) <-  rownamesfiltered      d3heatmap(data_filtered, colors = input$palette ,dendrogram =  "none",symm=false,rowv=false,colv=false,na.rm=true) })       # function play effect loading    loading_effect <-  function()({    # create 0-row data frame used store data    dat <- data.frame(x = numeric(0), y = numeric(0))    withprogress(message = 'making plot', value = 0, {     # number of times we'll go through loop     n <- 10      (i in 1:n) {       # each time through loop, add row of data.       # stand-in long-running computation.       dat <- rbind(dat, data.frame(x = rnorm(1), y = rnorm(1)))        # increment progress bar, , update detail text.       incprogress(1/n, detail = paste("doing part", i))        # pause 0.1 seconds simulate long computation.       sys.sleep(0.1)     }   }) })  }) 

ui.r

library(shiny) library(d3heatmap) library(shinythemes) library(markdown) require(rcolorbrewer)  shinyui(  navbarpage( title = 'iurc board', theme = shinytheme("cerulean"),  #  application title tabpanel("home",          fluidrow(            column(6,                   includemarkdown("home.md")            ),            column(3,                   img(class="img-polaroid",                       src=paste0("com.jpg")),                   tags$small(                     "source: google ",                     "place de la comédie"                    )            )          ) )       ,          navbarmenu("tools",             tabpanel('heatmap',                      sidebarlayout(                        sidebarpanel(                          h3("heatmap generator"),                           fileinput('file1', 'choose csv file', accept=c('text/csv', 'text/comma-separated-values,text/plain', '.csv')),                          textinput("gene",                                    "gene symbol:",                                    "spred1"),                         selectinput("palette", "palette", c("reds", "greens", "blues")),                                                      actionbutton("gobutton", "go!")                        ),                        mainpanel(                          #tableoutput("values"),                          includemarkdown("heatmap.md")                          )                      ),                      fluidrow(                         column(12,                              d3heatmapoutput("heatmap",  width = "auto") ,                               br(),                               br() )                      )               ),            tabpanel("about",                     fluidrow(                       column(6,                              includemarkdown("readme.md")                       ),                       column(3,                              img(class="img-polaroid",                                  src=paste0("carte.jpg")),                              tags$small(                                "source: google ",                                "montpellier localised near mediteranean sea")                       )                     )            )  )  )   ) 


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -