Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

Re: [R] regular expression

Prof Brian Ripley

2007-04-07

Replies:

On Sat, 7 Apr 2007, Laurent Rhelp wrote:

[...]

> I had had to modify the line below to allow for the connexion :
>
>   temp <- readLines(file(file.path(dirdata, "initial", i)))

You do not need the file() here.

> I didn't understand that readLines read all the file in one go, I
> understood that it read only one line !..so I did a loop on the lines of
> every file which is not necessary.

Please do read the help page for readLines, (very carefully before
posting). It says:

   readLines(con = stdin(), n = -1, ok = TRUE, warn = TRUE)

   con: a connection object or a character string.

    n: integer. The (maximal) number of lines to read. Negative
      values indicate that one should read up to the end of the
      connection.

   If the 'con' is a character string, the function calls 'file' to
   obtain a file connection which is opened for the duration of the
   function call.


--
Brian D. Ripley,            ripley@(protected)
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 272866 (PA)
Oxford OX1 3TG, UK           Fax: +44 1865 272595

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
©2008 r-help.com - Jax Systems, LLC, U.S.A.