R Shiny feature question

Hi,

I wish to develop a shiny app to solve a business problem. Now my final interface will include the results of outlier detection in the form of tables. I know how to do that.

But I wanted to add an additional functionality to it. I wanted to add a comment box where user after reading the results can type his response to tell me that they have done the checks on anomaly detected or can add any additional comment. I want there comments to be stored in a database which we can keep as a record.

Is this possible to do in Shiny?

Any help will be of value.

Thank you in advance :slight_smile:

Yep, it's possible, you could do something like this

library(shiny)
library(dplyr)
library(dbplyr)
library(DBI)
library(rlang)

mydb <- dbConnect(RSQLite::SQLite(), "my-db.sqlite")
if (!db_has_table(mydb, "info")) {
  dbCreateTable(mydb, "info", data.frame(user = character(0), info = character(0)))
}

ui <- fluidPage(
  dataTableOutput("table"),
  textInput("user_input", "Input info here"),
  actionButton("submit", "Submit info")
)

server <- function(input, output, session) {
  
  output$table <- renderDataTable({mtcars})
  
  observeEvent(input$submit, {
    d <- data.frame(
      user = session$user %||% "anonymous", 
      info = input$user_input
    )
    db_insert_into(mydb, "info", d)
  })
  
}

shinyApp(ui, server)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.