2

I have a very simple Shiny.

For some reason I get the errors
Error in formatNoSci(value) : argument "value" is missing, with no default
and
Error in force(ui) : object 'ui' not found.

I've googled these errors and can't find anything.

I can deduce that the ui isn't getting built for some reason, but I don't know why and I have no clue what formatNoSci does.

DF_custs <- data.frame(ID=c(1,2,3,3), val=c(10, 20, 100, 200))

## app.R ##
server <- function(input, output) {

  get_cust <- reactive({
    cust <- DF_custs[which(DF_custs$ID == input$num), ]
    return(cust$val)})

  output$result <- renderText({ 
    ans <- get_cust()
    paste("You chose: ", ans)})
    }

ui <- fluidPage(
      numericInput(inputId="num", label="Pick an ID: "),
      fluidRow(
        column(1,
               fluidRow(
                 wellPanel(

      mainPanel(textOutput("result"))))))
)

shinyApp(ui = ui, server = server)

Any advice would be greatly appreciated.

tumultous_rooster
  • 12,150
  • 32
  • 92
  • 149
  • 1
    in ` numericInput(inputId="num", label="Pick an ID: ")`, try defaulting the value to an ID that exists. If it defaults to null, I think it will try to run the reactive code in the server section and fail. – Alex Jul 09 '15 at 00:28
  • That most certainly fixed it! But why does it need a default value -- what if I'm piping in a csv and I actually don't know any values a priori? Seems sketch. – tumultous_rooster Jul 09 '15 at 00:30

1 Answers1

2

As per @Matt's comment, this is a problem with the initial state of the numericInput in ui being set to NULL, which triggers the reactive function in server. Some solutions would be to

  1. Error handling in server to check that the input is not NULL before trying to retrieve cust, or
  2. Initialising the ID to a default value which exists, or
  3. Converting numericInput to a button style input where the reactive function is not calculated until the user presses "submit".

See also this question: Shiny renderUI selectInput returned NULL

Community
  • 1
  • 1
Alex
  • 15,186
  • 15
  • 73
  • 127