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

strange behaviour on overwiting cells content #102

Open
pi-at-git opened this issue Jan 22, 2022 · 3 comments
Open

strange behaviour on overwiting cells content #102

pi-at-git opened this issue Jan 22, 2022 · 3 comments

Comments

@pi-at-git
Copy link

pi-at-git commented Jan 22, 2022

Hello! Thanks for this really amazing package. I hope you find the time to keep up with this the great work. Unfortunately, I noticed some strange behavior when I overwrite cell content. My objective is to to a plausibility check on manually entered values. In the attached minimal example, the decimal separator is changed in case someone entered a "," instead of a "." in column Sepal.Width (I used the excelR version form the official CRAN repo):

  • on start, the value of Sepal.Width, row 2 is "3"
  • if you overwrite "3" in Sepal.Width, row 2 with "3,3" it's automatically transformed into "3.3"
  • if you overwrite "3.3" in Sepal.Width, row 2 again with "3,3" it stays "3,3" (the "," is not changed to "." in the frontend, despite it's changed in the underlying table as you can see from the console)
  • if you now overwrite "3.2" in Sepal.Width, row 3 with "5,5", it not only corrects Sepal.Width, row 3 to "5.5" but also changes "3,3" to "3.3" in Sepal.Width, row 2
  • if you now overwrite "5.5" in Sepal.Width, row 3 again with "5,5", the "5.5" remains in the frontend
  • if you again overwrite "3.3" in Sepal.Width, row 2, "3,3" remains in row 2 and "5,5" remains in row 3

Here is my code:

library(shiny)
library(excelR)
library(data.table)

ui <- fluidPage(excelOutput("table1"))

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

   customReactVals <- reactiveValues(table1 = data.table(head(iris)))

   output$table1 <- renderExcel({
      excelTable(data = customReactVals$table1)
   })
 
   observeEvent(input$table1,{

      DT_table_data <- copy(data.table(excel_to_R(input$table1)))

      DT_table_data[, Sepal.Width := gsub(",",".", Sepal.Width, fixed=TRUE)]
      print(DT_table_data)

      customReactVals$table1 <- copy(DT_table_data)
        
   })

}

shinyApp(ui, server)

and here the output of my sessionInfo() [Ubuntu 20.04, but observed the same behavior on Windows and with RStudio RConnect server]
other attached packages: [1] data.table_1.14.0 excelR_0.4.0 shiny_1.6.0

@Swechhya
Copy link
Owner

@pi-at-git Can you download the latest development version and check if you are still facing this issue?

@pi-at-git
Copy link
Author

@Swechhya unfortunately, I see no difference. I'd like to doublecheck that I installed the latest dev version correctly. Can you please have a look at the following code:

install.packages("devtools")
install_github("Swechhya/excelR") # installed in a local directory below /home/test_user/

library(excelR, lib.loc="/home/test_user/R/x86_64-pc-linux-gnu-library/4.1") # avoid loading the "standard" version

sessionInfo()

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] excelR_0.4.0

@Swechhya
Copy link
Owner

@pi-at-git Can you let me know what type of behavior you expect in this case? Should it always change , to .?

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

No branches or pull requests

2 participants