[R] More on scan()
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Fri Dec 20 08:44:04 CET 2002
On Thu, 19 Dec 2002 apjaworski at mmm.com wrote:
> Here is one way of doing this.
> (1) read the whole file in as a vector of strings one line at a time
> x <- readLines("<path to your data file>")
> (2) find the position of the "@DATA" string in your vector
> s <- which(x == "@DATA")
> (3) scan the file again skipping s lines
> scan("<path to your data file>", skip=s, sep=",", ...)
Or use a file connection and read one line at a time until you find @DATA,
then call skip on the connection. That's the sort of thing connections
were intended for.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list