[R] Problem with choose.files(default=..., multi=FALSE)

Keith Jewell Keith.Jewell at campdenbri.co.uk
Tue May 9 18:06:06 CEST 2017


I'm very hesitant to suggest that there's a bug in such a venerable R 
function, but I can't see what I'm doing wrong. Any comments are welcome

When using choose.files() where:
     default = something
     multi = FALSE
     selected file path is shorter than the default
... then the returned value is at least as long as the default, 
characters from default appearing (wrongly) at the end of the returned 
value.

Example, in which all but the first choose.files() select 
"M:\\test\\target.dat". Note the last result.

 > pathlong <- choose.files(caption = "long")
 > pathlong # long file name to use as default for short selection
[1] 
"M:\\test\\Averyveryveryveryverylongfoldername\\Averyveryveryveryverylongfoldername\\Averyveryveryveryverylongfoldername\\target.dat"
 > choose.files(caption = "short")  # no default without multi works
[1] "M:\\test\\target.dat"
 > choose.files(default=pathlong, caption = "short") # default without 
multi= works
[1] "M:\\test\\target.dat"
 > choose.files(caption = "short", multi = FALSE) # multi = FALSE 
without default works
[1] "M:\\test\\target.dat"
 > choose.files(default=pathlong, caption = "short", multi = TRUE) # 
multi = TRUE with default works
[1] "M:\\test\\target.dat"
 > choose.files(default=pathlong, caption = "short", multi = FALSE) # 
multi = FALSE with default fails
[1] 
"M:\\test\\target.dat\\ryveryverylongfoldername\\Averyveryveryveryverylongfoldername\\Averyveryveryveryverylongfoldername\\target.dat"

 > # in case it's relevant
 > sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows Server 2008 R2 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United 
Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C 

[5] LC_TIME=English_United Kingdom.1252

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

other attached packages:
  [1] CBRIutils_1.0   stringr_1.2.0   svSocket_0.9-57 TinnR_1.0-5 
R2HTML_2.3.2
  [6] Hmisc_4.0-3     ggplot2_2.2.1   Formula_1.2-1   survival_2.41-3 
lattice_0.20-35

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-2  htmlTable_1.9       digest_0.6.12 
htmltools_0.3.6
  [5] splines_3.4.0       scales_0.4.1        grid_3.4.0 
checkmate_1.8.2
  [9] devtools_1.12.0     knitr_1.15.1        munsell_0.4.3 
compiler_3.4.0
[13] tibble_1.3.0        nnet_7.3-12         acepack_1.4.1 
Matrix_1.2-10
[17] svMisc_0.9-70       plyr_1.8.4          base64enc_0.1-3 
data.table_1.10.4
[21] stringi_1.1.5       magrittr_1.5        gtable_0.2.0 
colorspace_1.3-2
[25] foreign_0.8-68      cluster_2.0.6       gridExtra_2.2.1 
htmlwidgets_0.8
[29] withr_1.0.2         lazyeval_0.2.0      backports_1.0.5 
memoise_1.1.0
[33] rpart_4.1-11        Rcpp_0.12.10        latticeExtra_0.6-28
 >



More information about the R-help mailing list