tidyverse / googlesheets4

Google Spreadsheets R API (reboot of the googlesheets package)
https://googlesheets4.tidyverse.org
Other
360 stars 53 forks source link

sheet_append() function using , as decimal separator #235

Closed western11 closed 2 years ago

western11 commented 3 years ago

Hey, thanks for this amazing package, I have used it for quite a while and make my works much simpler. kudos for that.

I have a task to migrate an old shiny that using googlesheets package into googlesheets4 and I have a problem with sheet_append() function. There is no problem with the function but the produced output for numeric value using comma ( , ) as the decimal separator. Since the problem in the output and both code and sheet are confidential, I can't give you the screenshot but it's actually pretty straightforward to understand.

Below is the table example in my sheet. first row are numbers produces by old googlesheet package with gs_add_row function. the second row are numbers produces with sheet_append() function

0.81 | 0.87 | 0.8 | 0.74 -- | -- | -- | -- 0,45 | 0,62 | 0,5 | 0,25

About the code, I'm trying to export confusion matrix results into dataframe, where confMatScotClass() is a reactive value from shiny. You can just imagine that it's just a confusion matrix saved into a variable. The code below works fine in R where the value are detected as numeric but the problem just occur when appended into sheet like table above


sheet_append(ss = sss, 
                        sheet = "sheet_name", 
                        data = data.frame(Name = input$.username, 
                                           Accuracy = round(confMatScotClass()$overall[1],2),
                                           Recall = round(confMatScotClass()$byClass[1],2),
                                           Precision = round(confMatScotClass()$byClass[3],2),
                                           Specificity = round(confMatScotClass()$byClass[2],2),
                                           `Last Submitted` = format(Sys.time() %>% lubridate::with_tz(tzone = "Asia/Jakarta"), "%a, %b-%d %X %Y")))

It will be better if you guys can change the separator as ( . ) or maybe create a new optional parameter in the sheet_append() function where user can use either . or , as the separator.

jennybc commented 3 years ago

I can't reproduce this, so it has to be something specific to your Sheet and your usage.

library(googlesheets4)
dat <- data.frame(x = 1.1, y = 2.2)

ss <- gs4_create("sheet-append-reprex", sheets = list(dat = dat))
#> ✓ Creating new Sheet: "sheet-append-reprex".

read_sheet(ss)
#> ✓ Reading from "sheet-append-reprex".
#> ✓ Range 'dat'.
#> # A tibble: 1 x 2
#>       x     y
#>   <dbl> <dbl>
#> 1   1.1   2.2

dat2 <- data.frame(x = 3.3, y = 4.4)
ss %>%
  sheet_append(dat2)
#> ✓ Writing to "sheet-append-reprex".
#> ✓ Appending 1 row to 'dat'.

read_sheet(ss)
#> ✓ Reading from "sheet-append-reprex".
#> ✓ Range 'dat'.
#> # A tibble: 2 x 2
#>       x     y
#>   <dbl> <dbl>
#> 1   1.1   2.2
#> 2   3.3   4.4

Created on 2021-08-05 by the reprex package (v2.0.1.9000)

jennybc commented 2 years ago

This conversation seem to have gone quiet.