这是indexloc提供的服务,不要输入任何密码
Skip to content

using tmap_save() without a filename when file already exists does not yield useful error message #364

@stragu

Description

@stragu

When saving a tmap object to file without specifying a filename, and the file already exists, the error message is the following:

Error in sprintf("%02d", fid) : 
  invalid format '%02d'; use format %f, %e, %g or %a for numeric objects
In addition: Warning message:
In max(as.integer(substr(files, 5, 6))) :
  no non-missing arguments to max; returning -Inf

This makes it hard to understand what is going on (i.e. simply that it does not want to overwrite the file)

Could a more informative error message be implemented?

This can be tested with the following:

data(World)
m <- tm_shape(World) +
  tm_polygons()
tmap_save(m) # saves with default name "tmap.png"
tmap_save(m) # try it again

My session info:

R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

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

other attached packages:
[1] tmap_2.3-1        sf_0.8-0          dplyr_0.8.3       osmdata_0.1.1.007

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.5   purrr_0.3.3        lattice_0.20-38    viridisLite_0.3.0  htmltools_0.4.0   
 [6] yaml_2.2.0         XML_3.98-1.20      rlang_0.4.1        e1071_1.7-2        pillar_1.4.2      
[11] later_1.0.0        glue_1.3.1         DBI_1.0.0          sp_1.3-1           RColorBrewer_1.1-2
[16] stringr_1.4.0      rgeos_0.5-2        rvest_0.3.4        raster_3.0-7       htmlwidgets_1.5.1 
[21] leafsync_0.1.0     codetools_0.2-16   fastmap_1.0.1      httpuv_1.5.2       crosstalk_1.0.0   
[26] curl_4.2           class_7.3-15       Rcpp_1.0.2         KernSmooth_2.23-15 xtable_1.8-4      
[31] promises_1.1.0     classInt_0.4-2     lwgeom_0.1-7       leaflet_2.0.2      jsonlite_1.6      
[36] mime_0.7           digest_0.6.22      stringi_1.4.3      shiny_1.4.0        tmaptools_2.0-2   
[41] grid_3.6.1         rgdal_1.4-7        tools_3.6.1        magrittr_1.5       tibble_2.1.3      
[46] dichromat_2.0-0    crayon_1.3.4       pkgconfig_2.0.3    xml2_1.2.2         lubridate_1.7.4   
[51] assertthat_0.2.1   httr_1.4.1         rstudioapi_0.10    R6_2.4.0           units_0.6-5       
[56] compiler_3.6.1 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions