scan() + error interferes with count.fields() in some cases (PR#248)

maechler@stat.math.ethz.ch maechler@stat.math.ethz.ch
Fri, 13 Aug 1999 17:43:48 +0200 (MET DST)


As just mentioned on R-devel,
and originally reported (somewhat less concisely) by Adrian Trapletti,

This code

 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.64.2 and 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

>From my experiments, the problem seems to be the leading `` " '' ,
since the following also fails  {and btw mixes up ESS ...}

  write(c("\"A", "B", "C",1:3), nc=3)
  scan("data")         # gives error as it should
  count.fields("data") # 3 3
  count.fields("data") # >> Error in count.fields..: string terminated by nl..

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum SOL G1	Sonneggstr.33
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1086			<><

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._