0

I would like to generate a new html table every time the user changes the parameter "mass" below, and then exhibit it dynamically

server.R

library(hwriter)
shinyServer(function(input, output) {

    output$distPlot <- renderText({
        mass <- as.numeric(input$mass) 
        win <- as.numeric(input$sswin) 
        m1 <- mass-win/2
        m2 <- mass+win/2


        etr <- paste0("http://rest.kegg.jp/find/compound/", m1, "-", m2, "/exact_mass")
        tb <- read.table(etr)  
        colnames(tb) <- c("id", "mass")

        #p <- openPage('test.html')
        tblk <- cbind(paste0("http://www.kegg.jp/dbget-bin/www_bget?", tb[,1]), NA)
        #hwrite(tb, p, link = tblk)
        hwrite(tb, link = tblk)
        #close(p)

      })


})

ui.R

library(shiny)

shinyUI(fluidPage(


  sidebarLayout(
    sidebarPanel(

           textInput("mass", "Mass:", "200.05"),
           textInput("sswin", "Search window:", "0.5")

    ),


    # Show a plot of the generated distribution
    mainPanel(

      #plotOutput("distPlot"),
      #includeHTML("test.html")
      uiOutput("distPlot")


    )
  )
))

The table is being generated, but I don't know how to update it.

I figured out a way and edited above.

user1265067
  • 867
  • 1
  • 10
  • 26

1 Answers1

0

I encountered the very same problem as user1265067 and I found a solution to the problem.

Since this questions lacks an answer and in the case that other users stumble upon this thread, please find my solution (with a working toy example) in this thread: Shiny - populate static HTML table with filtered data based on input

In short, I wrap the static html table in a function, source it in the server and call it in the renderUI() function.

Community
  • 1
  • 1
Martin G.
  • 159
  • 1
  • 15