Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no longer possible to set numerical value to NA #1000

Closed
tverbeke opened this issue May 23, 2022 · 6 comments
Closed

no longer possible to set numerical value to NA #1000

tverbeke opened this issue May 23, 2022 · 6 comments
Labels

Comments

@tverbeke
Copy link

If you run the following example and push the button, it will correctly show a missing value (blank cell) in the table with DT 0.22 and will (erroneously) show a 0 with DT 0.23 (as well as with the current development version of DT).

library(shiny)
library(DT)
ui <- fluidPage(
    actionButton("go", "Go"),
    numericInput("obs", "Observations:", NA, min = 8, max = 100, step = 0.5),
    dataTableOutput("value")
)
server <- function(input, output, session) {
  
  observeEvent(input$go, {
        updateNumericInput(session, "obs", value = NA)
        cat(str(input$obs))
      })
  
  output$value <- renderDT({ datatable(data.frame(hello = input$obs))
      })
}
shinyApp(ui, server)
> xfun::session_info('DT')
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.4 LTS

Locale:
  LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                 
  LC_TIME=de_BE.UTF-8           LC_COLLATE=en_US.UTF-8       
  LC_MONETARY=de_BE.UTF-8       LC_MESSAGES=en_US.UTF-8      
  LC_PAPER=de_BE.UTF-8          LC_NAME=de_BE.UTF-8          
  LC_ADDRESS=de_BE.UTF-8        LC_TELEPHONE=de_BE.UTF-8     
  LC_MEASUREMENT=de_BE.UTF-8    LC_IDENTIFICATION=de_BE.UTF-8

Package version:
  base64enc_0.1.3   crosstalk_1.2.0   digest_0.6.29     DT_0.23.1        
  fastmap_1.1.0     graphics_4.1.2    grDevices_4.1.2   htmltools_0.5.2  
  htmlwidgets_1.5.4 jquerylib_0.1.4   jsonlite_1.8.0    later_1.3.0      
  lazyeval_0.2.2    magrittr_2.0.3    methods_4.1.2     promises_1.2.0.1 
  R6_2.5.1          Rcpp_1.0.8.3      rlang_1.0.2       stats_4.1.2      
  utils_4.1.2       yaml_2.3.5       

By filing an issue to this repo, I promise that

  • [ x] I have fully read the issue guide at https://yihui.name/issue/.
  • [ x] I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('DT'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/DT').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • [ x] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@yihui
Copy link
Member

yihui commented May 24, 2022

Sounds like it's caused by #987. @stla Do you have an idea?

@stla
Copy link
Collaborator

stla commented May 24, 2022

Good question. I've just tested in JS and null * 1 = 0. That should be the root cause. One has to treat null separately in the converter to numeric.

@yihui
Copy link
Member

yihui commented May 25, 2022

@stla Great! Could you help us fix it? Thanks a lot!

@stla
Copy link
Collaborator

stla commented May 25, 2022

Ok, will try to fix that today. JS arithmetic is strange ^^

@yihui
Copy link
Member

yihui commented May 27, 2022

@tverbeke This bug should be fixed now. You can install the development version via

remotes::install_github('rstudio/DT')

Thanks!

@tverbeke
Copy link
Author

Beautiful! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants