[R] regular expression

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Apr 7 19:22:22 CEST 2007


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 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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list