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

Mixed boolean and numeric values in a column causes read_excel to crash Rstudio but works fine from command line #758

Open
txemaheredia opened this issue Sep 25, 2024 · 0 comments

Comments

@txemaheredia
Copy link

I was having a ton of problems with read_excel crashing my Rstudio session. I googled around, tried the suggested methods of re-saving the excel in different tools, formats, or OS. Nothing worked.

Then, I tried to make a silly test in an Rscript to run it from the command line, to see if I got some additional output, and it simply worked flawlessly without crashing. From there, I found out that the culprit is having a mix of boolean and numeric values in the same column. Opening such excel crashes Rstudio, but works from command line giving a few warnings.

Might this help explain previous issues with these crashes?


Brief description of the problem

library(readxl)

# basedir<-"wherever/your/files/are"

file_crash <- file.path(basedir,"repexp_column_mixed.xlsx")
data <- readxl::read_excel(path = file_crash, 
                           sheet = "Sheet1",
                           col_names = F, 
                           trim_ws = T)
warnings()
dim(data)


file_noCrash <- file.path(basedir,"repexp_column_toNumber.xlsx")
data <- readxl::read_excel(path = file_noCrash, 
                           sheet = "Sheet1",
                           col_names = F, 
                           trim_ws = T)
warnings()
dim(data)

Running the "crash" chunk crashes Rstudio and gives this output in command line:

New names:
• `` -> `...1`
• `` -> `...2`
• `` -> `...3`
Warning messages:
1: Coercing boolean to numeric in C1 / R1C3
2: Coercing boolean to numeric in C3 / R3C3
3: Coercing boolean to numeric in C5 / R5C3
4: Coercing boolean to numeric in C7 / R7C3
[1] 7 3

Running the "non-crash" chunk works fine in Rstudio and gives this output in command line:

New names:
• `` -> `...1`
• `` -> `...2`
• `` -> `...3`
[1] 7 3

sessionInfo()

R version 4.4.0 (2024-04-24)
Platform: x86_64-apple-darwin20
Running under: macOS Monterey 12.7.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8

time zone: Europe/Madrid
tzcode source: internal

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

other attached packages:
[1] readxl_1.4.3

loaded via a namespace (and not attached):
 [1] compiler_4.4.0   magrittr_2.0.3   cli_3.6.3        tools_4.4.0     
 [5] pillar_1.9.0     glue_1.7.0       tibble_3.2.1     utf8_1.2.4      
 [9] fansi_1.0.6      cellranger_1.1.0 vctrs_0.6.5      lifecycle_1.0.4 
[13] pkgconfig_2.0.3  rlang_1.1.4  
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

1 participant