strange scan, count.fields --> BUG

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Fri, 13 Aug 1999 17:02:33 +0200


Adrian, you seem to report several things at once,...

I think, first you really don't want scan but rather read.table
with your file 

>> I have the following ascii file called "y.txt"
>> 
>> "USD-DEM" "USD-JPY" "DEM-JPY"
>>  0.344901 4.78712 4.442
>>  0.345715 4.7882 4.44189
>>  0.350657 4.79065 4.44177
>>  0.35347 4.79065 4.43616
>>  0.35368 4.78957 4.43622
>>  0.35361 4.78982 4.43669
>>  0.353821 4.79036 4.43622
>>  0.352767 4.78899 4.43634
>>  0.353119 4.78916 4.43545

which gives

R> str(read.table("y.txt",head=T))
`data.frame':  9 obs. of  3 variables:
 $ USD-DEM: num  0.345 0.346 0.351 0.353 0.354 ...
 $ USD-JPY: num  4.79 4.79 4.79 4.79 4.79 ...
 $ DEM-JPY: num  4.44 4.44 4.44 4.44 4.44 ...

---------

Then you report that  scan() leaves something ``behind'' {open file, ??}
after stopping with an error.
This is clearly a bug and is still present in the current 0.65 snapshot.
After a few tests, I see that the problem seems to happen only
(sometimes) when the text leading to the error contains a ` " ' .
The following is even simpler :

 write(c(paste("\"", LETTERS[1:3],"\"", sep=""),1:3), nc=3)
 scan("data")         # gives error as it should
 count.fields("data") # will be wrong
 count.fields("data") # is now ok : 3 3

Gives (in 0.65 snapshot)

    >  write(c(paste("\"", LETTERS[1:3],"\"", sep=""),1:3), nc=3)
    >  scan("data")         # gives error as it should
    Error: "scan" expected a real got ""A""
    >  count.fields("data") # will be wrong
    [1] 4 3
    >  count.fields("data") # is now ok : 3 3
    [1] 3 3

--> I'll report to R-bugs
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._