ycphs / openxlsx

openxlsx - a fast way to read and write complex xslx files
https://ycphs.github.io/openxlsx/
Other
220 stars 74 forks source link

`insertImage` and `insertPlot` unable to find image file in `R CMD check` under Linux and MacOS #406

Closed aravind-j closed 6 months ago

aravind-j commented 1 year ago

Describe the bug I am trying to add functionality in my R package augmentedRCBD to generate reports in MS excel using openxlsx package. I am facing an error in insertImage and insertPlot functions where it fails to find the image file under both Linux and MacOS during checking examples step in R CMD check. Otherwise the functions work fine and are able to find the file.

To Reproduce Here is an example using the R package with a single function TestinsertImage..

TestinsertImage <- function() {
  wb <- createWorkbook()
  modifyBaseFont(wb, fontSize = 10, fontName = "Arial")

  addWorksheet(wb, sheetName = "TestinsertImage", gridLines = FALSE)

  scdata <- structure(list(wt = c(2.62, 2.875, 2.32, 3.215, 3.44, 3.46, 3.57,
                                  3.19, 3.15, 3.44, 3.44, 4.07, 3.73, 3.78, 5.25, 5.424, 5.345,
                                  2.2, 1.615, 1.835, 2.465, 3.52, 3.435, 3.84, 3.845, 1.935, 2.14,
                                  1.513, 3.17, 2.77, 3.57, 2.78),
                           mpg = c(21, 21, 22.8, 21.4, 18.7,
                                   18.1, 14.3, 24.4, 22.8, 19.2, 17.8, 16.4, 17.3, 15.2, 10.4, 10.4,
                                   14.7, 32.4, 30.4, 33.9, 21.5, 15.5, 15.2, 13.3, 19.2, 27.3, 26,
                                   30.4, 15.8, 19.7, 15, 21.4)),
                      class = "data.frame",
                      row.names = c("Mazda RX4",
                                    "Mazda RX4 Wag", "Datsun 710", "Hornet 4 Drive", "Hornet Sportabout",
                                    "Valiant", "Duster 360", "Merc 240D", "Merc 230", "Merc 280",
                                    "Merc 280C", "Merc 450SE", "Merc 450SL", "Merc 450SLC", "Cadillac Fleetwood",
                                    "Lincoln Continental", "Chrysler Imperial", "Fiat 128", "Honda Civic",
                                    "Toyota Corolla", "Toyota Corona", "Dodge Challenger", "AMC Javelin",
                                    "Camaro Z28", "Pontiac Firebird", "Fiat X1-9", "Porsche 914-2",
                                    "Lotus Europa", "Ford Pantera L", "Ferrari Dino", "Maserati Bora",
                                    "Volvo 142E"))
  plot(x = scdata$wt, y = scdata$mpg)
  insertPlot(wb, sheet = "TestinsertImage",
              startRow = 36, startCol = 3, width = 6, height = 5)
  dev.off()

  saveWorkbook(wb, "insertImageExample.xlsx", overwrite = TRUE)
}
pkgpath <- "~/TestinsertImage"
devtools::load_all(path = pkgpath)
#> ℹ Loading TestinsertImage

# Works fine
TestinsertImage()

# Shows error when example is run in R CMD check
devtools::check(pkg = pkgpath, document = FALSE)
#> ══ Building ════════════════════════════════════════════════════════════════════
#> Setting env vars:
#> • CFLAGS    : -Wall -pedantic
#> • CXXFLAGS  : -Wall -pedantic
#> • CXX11FLAGS: -Wall -pedantic
#> • CXX14FLAGS: -Wall -pedantic
#> • CXX17FLAGS: -Wall -pedantic
#> • CXX20FLAGS: -Wall -pedantic
#> ── R CMD build ─────────────────────────────────────────────────────────────────
#> * checking for file ‘/media/aravindj/Cloud+GameDrive/Dropbox/R packages/Extras/TestinsertImage/DESCRIPTION’ ... OK
#> * preparing ‘TestinsertImage’:
#> * checking DESCRIPTION meta-information ... OK
#> * checking for LF line-endings in source and make files and shell scripts
#> * checking for empty or unneeded directories
#> Omitted ‘LazyData’ from DESCRIPTION
#> * building ‘TestinsertImage_0.1.0.tar.gz’
#> 
#> ══ Checking ════════════════════════════════════════════════════════════════════
#> Setting env vars:
#> • _R_CHECK_CRAN_INCOMING_USE_ASPELL_           : TRUE
#> • _R_CHECK_CRAN_INCOMING_REMOTE_               : FALSE
#> • _R_CHECK_CRAN_INCOMING_                      : FALSE
#> • _R_CHECK_FORCE_SUGGESTS_                     : FALSE
#> • _R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_: FALSE
#> • NOT_CRAN                                     : true
#> ── R CMD check ─────────────────────────────────────────────────────────────────
#> * using log directory ‘/tmp/RtmpvHwW6u/file4c6b54ff34bd/TestinsertImage.Rcheck’
#> * using R Under development (unstable) (2023-02-11 r83799)
#> * using platform: x86_64-pc-linux-gnu (64-bit)
#> * R was compiled by
#>     gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
#>     GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
#> * running under: Ubuntu 20.04.5 LTS
#> * using session charset: UTF-8
#> * using options ‘--no-manual --as-cran’
#> * checking for file ‘TestinsertImage/DESCRIPTION’ ... OK
#> * checking extension type ... Package
#> * this is package ‘TestinsertImage’ version ‘0.1.0’
#> * package encoding: UTF-8
#> * checking package namespace information ... OK
#> * checking package dependencies ... OK
#> * checking if this is a source package ... OK
#> * checking if there is a namespace ... OK
#> * checking for executable files ... OK
#> * checking for hidden files and directories ... OK
#> * checking for portable file names ... OK
#> * checking for sufficient/correct file permissions ... OK
#> * checking serialization versions ... OK
#> * checking whether package ‘TestinsertImage’ can be installed ... OK
#> * checking installed package size ... OK
#> * checking package directory ... OK
#> * checking for future file timestamps ... OK
#> * checking DESCRIPTION meta-information ... OK
#> * checking top-level files ... OK
#> * checking for left-over files ... OK
#> * checking index information ... OK
#> * checking package subdirectories ... OK
#> * checking R files for non-ASCII characters ... OK
#> * checking R files for syntax errors ... OK
#> * checking whether the package can be loaded ... OK
#> * checking whether the package can be loaded with stated dependencies ... OK
#> * checking whether the package can be unloaded cleanly ... OK
#> * checking whether the namespace can be loaded with stated dependencies ... OK
#> * checking whether the namespace can be unloaded cleanly ... OK
#> * checking loading without being on the library search path ... OK
#> * checking dependencies in R code ... OK
#> * checking S3 generic/method consistency ... OK
#> * checking replacement functions ... OK
#> * checking foreign function calls ... OK
#> * checking R code for possible problems ... OK
#> * checking Rd files ... OK
#> * checking Rd metadata ... OK
#> * checking Rd line widths ... OK
#> * checking Rd cross-references ... OK
#> * checking for missing documentation entries ... OK
#> * checking for code/documentation mismatches ... OK
#> * checking Rd \usage sections ... OK
#> * checking Rd contents ... OK
#> * checking for unstated dependencies in examples ... OK
#> * checking examples ... ERROR
#> Running examples in ‘TestinsertImage-Ex.R’ failed
#> The error most likely occurred in:
#> > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
#> > ### Name: TestinsertImage
#> > ### Title: TestinsertImage
#> > ### Aliases: TestinsertImage
#> > 
#> > ### ** Examples
#> > 
#> > TestinsertImage()
#> Error in insertImage(wb = wb, sheet = sheet, file = fileName, width = width,  : 
#>   File does not exist.
#> Calls: TestinsertImage -> insertPlot -> insertImage
#> Execution halted
#> * checking for non-standard things in the check directory ... OK
#> * checking for detritus in the temp directory ... OK
#> * DONE
#> Status: 1 ERROR
#> See
#>   ‘/tmp/RtmpvHwW6u/file4c6b54ff34bd/TestinsertImage.Rcheck/00check.log’
#> for details.
#> 
#> ── R CMD check results ────────────────────────────── TestinsertImage 0.1.0 ────
#> Duration: 19.7s
#> 
#> ❯ checking examples ... ERROR
#>   Running examples in ‘TestinsertImage-Ex.R’ failed
#>   The error most likely occurred in:
#>   
#>   > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
#>   > ### Name: TestinsertImage
#>   > ### Title: TestinsertImage
#>   > ### Aliases: TestinsertImage
#>   > 
#>   > ### ** Examples
#>   > 
#>   > TestinsertImage()
#>   Error in insertImage(wb = wb, sheet = sheet, file = fileName, width = width,  : 
#>     File does not exist.
#>   Calls: TestinsertImage -> insertPlot -> insertImage
#>   Execution halted
#> 
#> 1 error ✖ | 0 warnings ✔ | 0 notes ✔
#> Error: R CMD check found ERRORs
sessionInfo()
#> R Under development (unstable) (2023-02-11 r83799)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.5 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/libf77blas.so.3.10.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3;  LAPACK version 3.9.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_IN.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_IN.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_IN.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_IN.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Europe/Berlin
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] TestinsertImage_0.1.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] styler_1.9.0      utf8_1.2.3        stringi_1.7.12    digest_0.6.31    
#>  [5] magrittr_2.0.3    evaluate_0.20     pkgload_1.3.2     fastmap_1.1.0    
#>  [9] R.oo_1.25.0       R.cache_0.16.0    rprojroot_2.0.3   processx_3.8.0   
#> [13] R.utils_2.12.2    zip_2.2.2         pkgbuild_1.4.0    sessioninfo_1.2.2
#> [17] rcmdcheck_1.4.0   urlchecker_1.0.1  ps_1.7.2          promises_1.2.0.1 
#> [21] fansi_1.0.4       purrr_1.0.1       cli_3.6.0         shiny_1.7.4      
#> [25] rlang_1.0.6       crayon_1.5.2      R.methodsS3_1.8.2 ellipsis_0.3.2   
#> [29] reprex_2.0.2      remotes_2.4.2     withr_2.5.0       cachem_1.0.6     
#> [33] yaml_2.3.7        devtools_2.4.5    tools_4.3.0       memoise_2.0.1    
#> [37] httpuv_1.6.8      curl_5.0.0        vctrs_0.5.2       R6_2.5.1         
#> [41] mime_0.12         lifecycle_1.0.3   stringr_1.5.0     fs_1.6.1         
#> [45] htmlwidgets_1.6.1 xopen_1.0.0       usethis_2.1.6     miniUI_0.1.1.1   
#> [49] pkgconfig_2.0.3   desc_1.4.2        callr_3.7.3       pillar_1.8.1     
#> [53] openxlsx_4.2.5.2  later_1.3.0       glue_1.6.2        profvis_0.3.7    
#> [57] Rcpp_1.0.10       xfun_0.37         tibble_3.1.8      rstudioapi_0.14  
#> [61] knitr_1.42        xtable_1.8-4      htmltools_0.5.4   rmarkdown_2.20   
#> [65] compiler_4.3.0    prettyunits_1.1.1

Created on 2023-02-12 with reprex v2.0.2

Expected behavior insertImage and insertPlot should find the image file during R CMD check.

Example files Source package TestinsertImage_0.1.0.tar.gz for reproducing the issue. TestinsertImage_0.1.0.tar.gz

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 6 months ago

This issue was closed because it has been stalled for 7 days with no activity.