library(shiny) library(h2o)
wellPanel(style = "background: #FFF;", h4('Please enter the following information.'), flowLayout( numericInput("age", "age", value=NA), numericInput("bxgs1", "bxgs1", value=NA), numericInput("bxgs2", "bxgs2", value=NA), numericInput("bxgs", "bxgs", value=NA), numericInput("poscores", "poscores", value=NA), numericInput("psa", "psa", value=NA), selectInput("mi", "mi", c(NA, "No", "Yes"), selected=NA), numericInput("wgt", "wgt", value=NA), numericInput("totcores", "totcores", value=NA), selectInput("diab", "diab", c(NA, "No", "Yes"), selected=NA) ), br(), actionButton('tx_start','Calculate') ) conditionalPanel('input.tx_start>0', wellPanel(id='tx_results',style = "background: #FFF;", h3('H2O output: '), h5(dataTableOutput('pred_score')) )) # Reactive function to calculate h2o score calculate_h2o = reactive({ # assign variables age = as.numeric(input$age) bxgs1 = as.numeric(input$bxgs1) bxgs2 = as.numeric(input$bxgs2) bxgs = as.numeric(input$bxgs) poscores = as.numeric(input$poscores) psa = as.numeric(input$psa) mi = input$mi wgt = as.numeric(input$wgt) totcores = as.numeric(input$totcores) diab = input$diab # create data frame x <- data.frame( age, bxgs1, bxgs2, bxgs, poscores, psa, mi, wgt, totcores, diab) # call mojo pred_rf <- h2o.mojo_predict_df(frame=x, mojo_zip_path="tx_model_nomets_pub.zip", genmodel_jar_path='h2o-genmodel.jar', verbose = F) pred_rf }) output$pred_score = renderDataTable(calculate_h2o(), options=list(paging=FALSE, searching=FALSE, info=FALSE, scrollX=TRUE ))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.