I have a problem with renderUI and I couldn't find a solution anywhere. Probably I'm asking the wrong question to google and more than a shiny problem is a basic R problem.
I have a function in R which depending on the input will return a table or a text. So I created both the options in my server.R in this way:
output$table <- renderTable {(
x <- function (y)
print(x)
)}
output$text <- renderText {(
x <- function (y)
print(x)
)}
If I put both the outputs in renderUI one will always give me an error. In case of textOutput if the output is a table:
Error: argument 1 (type 'list') cannot be handled by 'cat'
and
Error:no applicable method for 'xtable' applied to an object of class "character"
if it is viceversa.
My question is there a way to catch this error and use an if statement within renderUI to display only one of the two? I'm here to give you more details if you need.
[EDIT]
server.R
library(shiny)
library(drsmooth)
shinyServer(function(input, output,session) {
-- upload dataframe and input management goes here --
output$nlbcd <- renderTable({
nlbcd<-nlbcd(dosecolumn="Dose", targetcolumn=response(),cutoffdose=cutoff(),data=data1())
print(nlbcd)
})
output$nlbcdText <- renderText({
nlbcd<-nlbcd(dosecolumn="Dose", targetcolumn=response(),cutoffdose=cutoff(),data=data1())
print(nlbcd)
})
output$tb <- renderUI({
tableOutput("nlbcd"),
textOutput("nlbcdText")
})
})