[R] File reading.

Randall Skelton rhskelto at atm.ox.ac.uk
Wed Oct 17 14:52:42 CEST 2001


Indeed it was the 'file' command that I was missing.  Passing this object
through to 'scan' does what I was looking for.

> a<-file("Xtemp", "r", blocking = TRUE)
> b<-scan(a, what=list(nx=0, ny=0), n=2)
Read 1 records
> c<-scan(a, what=list(xlab=0), n=b$nx)
Read 39 records

The 'scan' documentation doesn't really explain this very well...

|     scan(file = "", what = double(0), nmax = -1, n = -1, sep = "",
|          quote = if (sep=="\n") "" else "'\"", dec = ".",
|          skip = 0, nlines = 0, na.strings = "NA",
|          flush = FALSE, fill = FALSE, strip.white = FALSE, quiet = FALSE,
|          blank.lines.skip = TRUE, multi.line = TRUE)

Thanks!
Randall

On Wed, 17 Oct 2001, Roger Bivand wrote:

> Maybe try file(), open(), and readLines(), see Brian Ripley's introduction
> to using connections in R-News number 1, pages 16-17.


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list