Re: [Rd] Clarification for readChar man page

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Thu, 14 Jun 2007 11:11:29 -0400

On 6/14/2007 10:49 AM, Jeffrey Horner wrote:
> Hi,
>
> Here's a patch to the readChar manual page (R-trunk as of today) that
> better clarifies readChar's return value.

Your update is not right. For example:

x <- as.raw(32:96)
readChar(x, nchars=rep(2,100))

This returns a character vector of length 100, of which the first 32 elements have 2 chars, the next one has 1, and the rest are "".

So the length of nchars really does affect the length of the value.

Now, I haven't looked at the code, but it's possible we could delete the "(which might be less than \code{length(nchars)})" remark, and if not, it would be useful to explain the situations in which the return value could be shorter than the nchars vector.

Duncan Murdoch

It could use some work as I'd
> also like to add some text about using nchar() to find the length of the
> string that readchar() returns, but I'm unsure which of type="bytes" or
> type="chars" to mention. Is it type="chars"?
>
> Index: src/library/base/man/readChar.Rd
> ===================================================================
> --- src/library/base/man/readChar.Rd (revision 41943)
> +++ src/library/base/man/readChar.Rd (working copy)
> @@ -57,8 +57,8 @@
> }
>
> \value{
> - For \code{readChar}, a character vector of length the number of
> - items read (which might be less than \code{length(nchars)}).
> + For \code{readChar}, a character vector of length 1 with the number
> + of characters less than or equal to nchars.
>
> For \code{writeChar}, a raw vector (if \code{con} is a raw vector) or
> invisibly \code{NULL}.
>
>
> Jeff



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 14 Jun 2007 - 15:45:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 14 Jun 2007 - 20:36:57 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.