[Rd] Weirdness with choose.files on Microsoft Windows (PR#6818)

kwright at eskimo.com kwright at eskimo.com
Fri Apr 23 23:55:56 CEST 2004


Full_Name: Kevin Wright
Version: 1.8.0
OS: Windows 95
Submission from: (NULL) (170.54.59.160)



This bug also happens to me using R 1.9.0 on Windows 2000.

Took me a long time to create a reproducible bug, but I think I have succeeded. 
I suspect my test function has a bug, but I don't see anything wrong.  Plus, the
bug only shows up when selecting certain filenames.  Nearest I can speculate,
choose.files becomes confused after a filename that has capital letters and
numbers has been chosen.  Sounds crazy and I'd like to know more, but
choose.files is mostly .Internal code.

First, create two CSV files.

library(nlme)
data(Oats)
write.table(Oats,"c:/oats.csv",sep=",")
write.table(Oats,"c:/C20oats.csv",sep=",")

Quit R and restart.  Follow the steps below.  Select oats.csv the first 4 times,
then select C20oats.csv and then select oats.csv .  Notice how the filename is
corrupted the final  time.


test <- function(){
     cat("press ENTER for a gui file selector\n")
     gas.filename<-readline()
     if(gas.filename=="")
       gas.filename <- choose.files("*.csv",multi=FALSE,caption="Hi")
     if(file.exists(gas.filename)){
       cat("Reading ",gas.filename,"\n")
       DFgas<-read.csv(gas.filename)
     }
     else
       cat("The file",gas.filename," cannot be found\n")
 
 
     cat("press ENTER for a gui file selector\n")
     nir.filename<-readline()
     if(nir.filename=="")
       nir.filename <- choose.files("*.csv",multi=FALSE,
                                    caption="Choose one gas CSV file")
     if(file.exists(nir.filename)){
       cat("Reading ",nir.filename,"\n")
       DFnir<-read.csv(nir.filename)
     }
     else
       cat("The file", nir.filename," cannot be found\n")      
       
 }

> test()
press ENTER for a gui file selector

Reading  C:\oats.csv 
press ENTER for a gui file selector

Reading  C:\oats.csv 
> test()
press ENTER for a gui file selector

Reading  C:\oats.csv 
press ENTER for a gui file selector

Reading  C:\oats.csv 
> test()
press ENTER for a gui file selector

Reading  C:\C20oats.csv 
press ENTER for a gui file selector

The file C:\oats.csv\sv  cannot be found
>



More information about the R-devel mailing list