Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201867

Can we check shiny applications using testthat and usethis

$
0
0

is there a way to check the below applications. This is a sample application to display selected rows. But in general is there a way to acheive this. For example the below code is perfect. Suppose I may some errors in this and I need to check all in once. Can we do that? I have also pasted the error code down

Correct

library(shiny)
library(DT)

ui <- basicPage(
  mainPanel(DT::dataTableOutput('mytable')),
  textOutput("selected")
)

server <- function(input, output,session) {

  mydata <- reactive({mtcars})

  output$mytable = DT::renderDataTable(    
    datatable(mydata())
  ) 

  selectedRow <- eventReactive(input$mytable_rows_selected,{
    row.names(mtcars)[c(input$mytable_rows_selected)]
  })

  output$selected <- renderText({ 
    selectedRow()
  })
}
runApp(list(ui = ui, server = server))

Wrong/Error code

library(shiny)
library(DT)

ui <- basicPage(
  mainPanel(DT::dataTableOutput('mytable')),
  textOutput("selected")
)

server <- function(input, output,session) {

  mydata <- reactive({mtcars})

  output$mytable = DT::renderDataTable(    
    datatable(mydata())
  ) 

  selectedRow <- eventReactive(input$mytable_rows_selected,{
    row.names(mtcars)[c(input$[mytable_rows_selected])]
  })

  output$selected <- renderText({ 
    selectedRow
  })
}
runApp(list(ui = ui, server = server))

Viewing all articles
Browse latest Browse all 201867

Trending Articles