awalker89 / openxlsx

R package for .xlsx file reading and writing.
Other
364 stars 79 forks source link

Failed to load column names and some of the values are treated as NA #430

Open hidekoji opened 6 years ago

hidekoji commented 6 years ago

Expected Behavior

I have a excel file that looks like this.

image

It should detect column names and should show the actual value instead of NA

Actual Behavior

It fails to detect column names and show NA for some of the cells

Steps to Reproduce the Problem

Here is the xls file (https://www.dropbox.com/s/8qie0lpnxe8k0qn/Global_Sales.xlsx?dl=1) and Here is the reproducible R code

library(reprex)
reprex::reprex({
df <- openxlsx::read.xlsx(xlsxFile = "https://www.dropbox.com/s/8qie0lpnxe8k0qn/Global_Sales.xlsx?dl=1", sheet = "Sheet1", colNames = TRUE, startRow = 1, na.strings = c('','NA'), skipEmptyRows = FALSE, skipEmptyCols = FALSE, check.names = FALSE, detectDates = FALSE)
head(df,10)
})

#>    X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16   221.98 2   0
#> 1  NA NA NA NA NA NA NA NA NA  NA  NA  NA  NA  NA  NA  NA 3709.395 9 0.1
#> 2  NA NA NA NA NA NA NA NA NA  NA  NA  NA  NA  NA  NA  NA 5175.171 9 0.1
#> 3  NA NA NA NA NA NA NA NA NA  NA  NA  NA  NA  NA  NA  NA 2892.510 5 0.1
#> 4  NA NA NA NA NA NA NA NA NA  NA  NA  NA  NA  NA  NA  NA 2832.960 8 0.0
#> 5  NA NA NA NA NA NA NA NA NA  NA  NA  NA  NA  NA  NA  NA 2862.675 5 0.1
#> 6  NA NA NA NA NA NA NA NA NA  NA  NA  NA  NA  NA  NA  NA 1822.080 4 0.0
#> 7  NA NA NA NA NA NA NA NA NA  NA  NA  NA  NA  NA  NA  NA 5244.840 6 0.0
#> 8  NA NA NA NA NA NA NA NA NA  NA  NA  NA  NA  NA  NA  NA  341.960 2 0.0
#> 9  NA NA NA NA NA NA NA NA NA  NA  NA  NA  NA  NA  NA  NA   48.712 1 0.2
#> 10 NA NA NA NA NA NA NA NA NA  NA  NA  NA  NA  NA  NA  NA   17.940 3 0.0
#>    62.15440000000001  40.77 X22 FALSE
#> 1             0.0000 923.63  NA FALSE
#> 2           919.9710 915.49  NA FALSE
#> 3             0.0000 910.16  NA FALSE
#> 4           311.5200 903.04  NA FALSE
#> 5           763.2750 897.35  NA FALSE
#> 6           564.8400 894.77  NA FALSE
#> 7           996.4800 878.38  NA FALSE
#> 8            54.7136  25.27  NA FALSE
#> 9             5.4801  11.13  NA FALSE
#> 10            4.6644   4.29  NA FALSE

sessionInfo()

R version 3.5.1 (2018-07-02) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS 10.14

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

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

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

other attached packages: [1] reprex_0.2.1 exploratory_0.7.4.2

loaded via a namespace (and not attached): [1] zoo_1.8-1 tidyselect_0.2.4 reshape2_1.4.3 purrr_0.2.4 lattice_0.20-35 colorspace_1.3-2 htmltools_0.3.6
[8] base64enc_0.1-3 yaml_2.1.19 rlang_0.2.1 pillar_1.2.2 foreign_0.8-70 glue_1.2.0 readxl_1.1.0
[15] bindrcpp_0.2.2 foreach_1.4.4 bindr_0.1.1 plyr_1.8.4 anonymizer_0.2.0 stringr_1.3.0 munsell_0.4.3
[22] gtable_0.2.0 cellranger_1.1.0 zip_1.0.0 evaluate_0.10.1 codetools_0.2-15 psych_1.8.4 knitr_1.20
[29] callr_3.0.0 ps_1.2.0 parallel_3.5.1 urltools_1.7.0 triebeard_0.3.0 broom_0.4.4 Rcpp_0.12.16
[36] clipr_0.4.1 scales_0.5.0 backports_1.1.2 fs_1.2.6 mnormt_1.5-5 ggplot2_2.2.1 digest_0.6.15
[43] stringi_1.2.2 openxlsx_4.1.0 processx_3.2.0 dplyr_0.7.5 dtw_1.18-1 grid_3.5.1 rprojroot_1.3-2
[50] tools_3.5.1 magrittr_1.5 lazyeval_0.2.1 proxy_0.4-22 tibble_1.4.2 crayon_1.3.4 whisker_0.3-2
[57] tidyr_0.8.1 pkgconfig_2.0.1 data.table_1.11.4 rstudioapi_0.7 assertthat_0.2.0 rmarkdown_1.9 iterators_1.0.9
[64] R6_2.2.2 nlme_3.1-137 compiler_3.5.1