Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.33.0110171347210.1323-100000@mulligan.atm.ox.ac.uk>
Date: 2001-10-17T12:52:42Z
From: Randall Skelton
Subject: File reading.
In-Reply-To: <Pine.LNX.4.21.0110171349320.14209-100000@reclus.nhh.no>

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