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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Keith Jewell-2
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
 >

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with choose.files(default=..., multi=FALSE)

Duncan Murdoch-2
On 09/05/2017 12:06 PM, Keith Jewell wrote:
> 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

Yes, it looks like a bug.  One other thing I find a little strange: the
starting directory seems wrong when I have the pathlong default.  Did
you see that?  (I'm in Windows 10, not the same version as you.)

Duncan Murdoch

>
> 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
>  >
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with choose.files(default=..., multi=FALSE)

Keith Jewell-2
Thanks for confirming that I wasn't being stupid :-}

When using default=pathlong I get the _correct_ starting directory...
(M:\test\Averyveryveryveryverylongfoldername\Averyveryveryveryverylongfoldername\Averyveryveryveryverylongfoldername)

... both in the environment I indicated originally (Windows Server 2008
R2 x64) and also in Windows 10 x64

Keith Jewell

On 09/05/2017 17:49, Duncan Murdoch wrote:

> On 09/05/2017 12:06 PM, Keith Jewell wrote:
>> 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
>
> Yes, it looks like a bug.  One other thing I find a little strange: the
> starting directory seems wrong when I have the pathlong default.  Did
> you see that?  (I'm in Windows 10, not the same version as you.)
>
> Duncan Murdoch
>
>>
>> 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
>>  >
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with choose.files(default=..., multi=FALSE)

Duncan Murdoch-2
On 10/05/2017 6:46 AM, Keith Jewell wrote:
> Thanks for confirming that I wasn't being stupid :-}
>
> When using default=pathlong I get the _correct_ starting directory...
> (M:\test\Averyveryveryveryverylongfoldername\Averyveryveryveryverylongfoldername\Averyveryveryveryverylongfoldername)
>
> ... both in the environment I indicated originally (Windows Server 2008
> R2 x64) and also in Windows 10 x64

This should now be fixed in R-patched and R-devel, as of revision 72703.
  The issue was that the Windows API function returned its results in a
slightly different format when multi=FALSE.  When there was no default
or a short one, the two formats happened to look identical so we didn't
notice this, but they differed when the default was longer than the result.

Duncan Murdoch

>
> Keith Jewell
>
> On 09/05/2017 17:49, Duncan Murdoch wrote:
>> On 09/05/2017 12:06 PM, Keith Jewell wrote:
>>> 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
>>
>> Yes, it looks like a bug.  One other thing I find a little strange: the
>> starting directory seems wrong when I have the pathlong default.  Did
>> you see that?  (I'm in Windows 10, not the same version as you.)
>>
>> Duncan Murdoch
>>
>>>
>>> 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
>>>  >
>>>
>>> ______________________________________________
>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.