[R] readLines() *does not* change mode of connection

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Mon Dec 2 09:14:50 CET 2002


The `text' field is *not* the mode: look at your own output.

This is expected.  In your first output the connection has not been
opened.  You asked provisionally for a binary mode, but this is
provisional until the connection has actually been opened.
readLines does open the connection.

The fields of a connection are not documented.

On Sun, 1 Dec 2002, Vadim Ogranovich wrote:

> Hi,
>
> It seems like reading a line from a gzfile() connection changes the mode of
> the connection from text to binary (it also alters "can write", in case it
> matters). The following transcript, produced on RedHat 7.1, demonstrates
> this "feature" (note the evolution of file$text). Is this expected?
>
> Thanks, Vadim
>
>
> > file <- gzfile("foo.gz")
> file <- gzfile("foo.gz")
> > summary(file)
> summary(file)
> $description
> [1] "foo.gz"
>
> $class
> [1] "gzfile"
>
> $mode
> [1] "rb6"
>
> $text
> [1] "text"
>
> $opened
> [1] "closed"
>
> $"can read"
> [1] "yes"
>
> $"can write"
> [1] "yes"
>
> > hdr <- readLines(file, 1)
> hdr <- readLines(file, 1)
> > summary(file)
> summary(file)
> $description
> [1] "foo.gz"
>
> $class
> [1] "gzfile"
>
> $mode
> [1] "rb6"
>
> $text
> [1] "binary"
>
> $opened
> [1] "closed"
>
> $"can read"
> [1] "yes"
>
> $"can write"
> [1] "no"
>
>
>
> --------------------------------------------------
> DISCLAIMER
> This e-mail, and any attachments thereto, is intended only for use by the
> addressee(s) named herein and may contain legally privileged and/or
> confidential information.  If you are not the intended recipient of this
> e-mail, you are hereby notified that any dissemination, distribution or
> copying of this e-mail, and any attachments thereto, is strictly prohibited.
> If you have received this e-mail in error, please immediately notify me and
> permanently delete the original and any copy of any e-mail and any printout
> thereof.
>
> E-mail transmission cannot be guaranteed to be secure or error-free.  The
> sender therefore does not accept liability for any errors or omissions in
> the contents of this message which arise as a result of e-mail transmission.
>
> NOTICE regarding privacy and confidentiality
>
> Knight Trading Group may, at its discretion, monitor and review the content
> of all e-mail communications.
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

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

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