[I originally sent this to R-bugs@stat.math.ethz.ch and it didn't
bounce, but when I received no response I thought I had better check to
see if I had the correct address.]
System: Sun Solaris 2.5.1
R: Version 0.65.1 Release (October 07, 1999)
There seem to be at least 2 bugs associated with the use of flush=T in
the scan function.
1) If flush=T is used, scan() will only ask for 1 line from standard input.
Repeat by:
> scan(what=list(c1=0,c2=0,c3=0), flush=T)
1: 1 2 3 4
Read 1 lines
$c1
[1] 1
$c2
[1] 2
$c3
[1] 3
>
1a) If the 'correct' number of fields are supplied, then two lines are
read, but only 1 is 'registered':
> scan( what=list(c1=0,c2=0,c3=0),flush=T)
1: 1 2 3
1: 4 5 6
Read 1 lines
$c1
[1] 1
$c2
[1] 2
$c3
[1] 3
>
2) When reading from a file, the first line is processed correctly, but
the second and subsequent lines do not have the extraneous data flushed
correctly. Repeat by:
> write(t(matrix(1:15, ncol=5, byrow=T)), "tmp")
> system("cat tmp")
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15> scan("tmp", what=list(c1=0,c2=0,c3=0), flush=T)
Read 4 lines
$c1
[1] 1 6 10 3
$c2
[1] 2 7 11 14
$c3
[1] 3 8 12 15
Warning message:
line 3 did not have 3 elements>
Notice that on lines 2 and 3 the first character of the "flushable
data" (after the field separator) does get flushed, but then scanning
continues. Pehaps an end-of-line indication is not reset?
Ray Brownrigg
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._