DillonHammill / DataEditR

An Interactive R Package for Viewing, Entering Filtering and Editing Data
https://dillonhammill.github.io/DataEditR/
384 stars 40 forks source link

How can I fix "Error in type.convert.default"? #33

Open cognitivepsychology opened 3 years ago

cognitivepsychology commented 3 years ago

Hi, Mr. Hammill,

I installed DataEditR through the CRAN. Actually, at first it worked fine, but at some point I started receiving errors. My data frame (usually tibble format) is not displayed at the pop-up dialog window when I run the data_edit function. Though the pop-up appears a few seconds, it always fleetingly is shut with the following error message:

data_edit(my_data)
필요한 패키지를 로딩중입니다: shiny

Listening on http://127.0.0.1:7744
Warning: Setting row names on a tibble is deprecated.
Warning: Error in type.convert.default: invalid multibyte string at '<eb><85><b8>
  68: type.convert.default
  66: type.convert.data.frame
  64: data_format
  63: <reactive>
  47: data_update
  46: <observer>
   3: shiny::runApp
   2: runGadget
   1: data_edit

My session information is as followings:

> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=Korean_Korea.949  LC_CTYPE=Korean_Korea.949    LC_MONETARY=Korean_Korea.949 LC_NUMERIC=C                 LC_TIME=Korean_Korea.949    

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

other attached packages:
 [1] shiny_1.6.0      optimx_2021-6.12 lmerTest_3.1-3   lme4_1.1-27.1    Matrix_1.3-4     hypr_0.2.2       EnvStats_2.4.0   bit64_4.0.5      bit_4.0.4       
[10] broom_0.7.9      psycho_0.6.1     psych_2.1.6      pastecs_1.3.21   gt_0.3.1         mmtable2_0.1.3   DataEditR_0.1.3  writexl_1.4.0    readxl_1.3.1    
[19] forcats_0.5.1    stringr_1.4.0    dplyr_1.0.7      purrr_0.3.4      readr_2.0.1      tidyr_1.1.3      tibble_3.1.4     ggplot2_3.3.5    tidyverse_1.3.1 

loaded via a namespace (and not attached):
 [1] nlme_3.1-152        fs_1.5.0            lubridate_1.7.10    httr_1.4.2          numDeriv_2016.8-1.1 bslib_0.3.0         tools_4.1.1         backports_1.2.1    
 [9] utf8_1.2.2          R6_2.5.1            DBI_1.1.1           colorspace_2.0-2    withr_2.4.2         tidyselect_1.1.1    mnormt_2.0.2        compiler_4.1.1     
[17] cli_3.0.1           rvest_1.0.1         xml2_1.3.2          shinyjs_2.0.0       rhandsontable_0.3.8 sass_0.4.0          scales_1.1.1        digest_0.6.27      
[25] minqa_1.2.4         shinyBS_0.61        pkgconfig_2.0.3     htmltools_0.5.2     dbplyr_2.1.1        fastmap_1.1.0       htmlwidgets_1.5.3   rlang_0.4.11       
[33] rstudioapi_0.13     jquerylib_0.1.4     generics_0.1.0      jsonlite_1.7.2      magrittr_2.0.1      Rcpp_1.0.7          munsell_0.5.0       fansi_0.5.0        
[41] lifecycle_1.0.0     yaml_2.2.1          stringi_1.7.4       MASS_7.3-54         grid_4.1.1          parallel_4.1.1      promises_1.2.0.1    crayon_1.4.1       
[49] miniUI_0.1.1.1      lattice_0.20-44     splines_4.1.1       haven_2.4.3         hms_1.1.0           tmvnsim_1.0-2       pillar_1.6.2        boot_1.3-28        
[57] reprex_2.0.1        glue_1.4.2          modelr_0.1.8        nloptr_1.2.2.2      vctrs_0.3.8         tzdb_0.1.2          httpuv_1.6.2        cellranger_1.1.0   
[65] gtable_0.3.0        assertthat_0.2.1    cachem_1.0.6        mime_0.11           xtable_1.8-4        pracma_2.3.3        later_1.3.0         shinythemes_1.2.0  
[73] ellipsis_0.3.2 

As long as I change my locale to "Sys.setlocale(category = "LC_ALL", locale = "English")", the data_edit function seems to work fine. However, the problem is then, that I can't see any Korean character strings in my data frame any more because my locale was set to English! How can I fix this problem? I greatly appreciate if you give me any useful advice. Thank you for your time.

Best, Galaxy

DillonHammill commented 3 years ago

@cognitivepsychology, definitely looks like an issue caused by non-ASCII characters in your data. Unfortunately I don't have any experience trying to work with such characters in R, but from what I have read it seems that it is important to set the locale and encoding when reading in the data. Not sure how you have read your data into R, but since it is a tibble I suspect that maybe used read_csv()? Perhaps you could try the following when reading in your data and then pass that to data_edit()?

library(readr)
locale("ko")

my_data <- read_csv(file = "my_data.csv", 
                                  locale = locale(date_names = "ko", encoding = "UTF-8"))
cognitivepsychology commented 3 years ago

Thank you for your answer, Mr. Hammill. Unfortunately, it seems that I didn't set the locale and the encoding properly when I read my data at first. Since I already walked a too long long code-way from the point of importing the data, it is almost impossible to re-read my data at this moment to fix the problem. However, I'll definitely try your suggestion next time. Thank you for your advice and your great package.

Best, Galaxy