Closed hcstubbe closed 2 years ago
Thanks for the report. Some clarifying questions:
verbatimTextOutput("value")
?Hi, thank you for getting back to me!
input$obs
returns 0 instead of NA. Therefore, 0 is shown instead of NA in verbatimTextOutput("value")
. input$obs
can return NA again.EDIT:
simply adding DT::datatable(iris)
to the ui changes the behavior of the numericInput()
(the code is the example from ?numericInput
):
## Only run examples in interactive R sessions
if (interactive()) {
ui <- fluidPage(
numericInput("obs", "Observations:", 10, min = 1, max = 100),
verbatimTextOutput("value"),
DT::datatable(iris) # This line changes the behavior of numericInput()
)
server <- function(input, output) {
output$value <- renderText({ input$obs })
}
shinyApp(ui, server)
}
Wow, confirmed on Windows 10, R 4.2.0. Exactly as you said--without the DT, no issue. And it doesn't happen on macOS R 4.1.2. What in the world??
OK, mystery solved. It's an issue in DT that has since been fixed, but not yet released on CRAN. If you remotes::install_github("rstudio/DT")
, you should be good.
When using the latest version of R (4.2.0 or 4.2.1, both on Windows 11 or Ubuntu 20.04.4 LTS), the numericInput() returns 0 instead of NA, when no value or a string are entered, if DT::renderDT() is used to render a table.
I also referenced this problem here.
System details
Output of
sessionInfo()
(Windows 11 and Ubuntu 20.04.4 LTS):Ubuntu 20.04.4 LTS:
Windows 11:
Example application
After launching the application delete the input or enter a character.
Describe the problem in detail
When using the latest version of R (4.2.0 or 4.2.1, both on Windows 11 or Ubuntu 20.04.4 LTS), the numericInput() returns 0 instead of NA, when no value or a string are entered, if DT::renderDT() is used to render a table. I tested this for the latest R version (4.2.0 and 4.2.1) and on Ubuntu and Windows (see above). This problem is absent in older R versions (e.g. R version 4.1.2). In a data app, where empty values need to be represented as NA, this is a huge problem.