[R] readBin documentation error

Duncan Murdoch murdoch.duncan at gmail.com
Sat Sep 3 11:23:51 CEST 2016


On 03/09/2016 3:56 AM, peter dalgaard wrote:
>
>> On 03 Sep 2016, at 03:24 , Yucheng Song via R-help <r-help at r-project.org> wrote:
>>
>> Thanks for the reply. What I meant was that there is no int(), if you do a ?readBin, you will find it there.
>
> Not as far as I can tell:
>
>     what: Either an object whose mode will give the mode of the vector
>           to be read, or a character vector of length one describing
>           the mode: one of ‘"numeric"’, ‘"double"’, ‘"integer"’,
>           ‘"int"’, ‘"logical"’, ‘"complex"’, ‘"character"’, ‘"raw"’.
>
> Note: Either...or...
>
> I.e., you can use a character string (==vector of length one)
>
> readBin(zz, "int", 8, size = 1)
>
> and you can use an object of the desired mode
>
> readBin(zz, integer(), ...) or equivalently readBin(zz, 0L, ...)
>
> but there is no implication that each of the possible character strings have a corresponding function.

> It is not clear why we allow  both "int" and "integer" here, but there is no reason to expect int() to exist.


Partial matching isn't allowed on the names (because a length one 
character vector implies 'what = "character"' unless it happens to 
contain one of those strings), so this is a way to allow a common 
readable abbreviation.

Duncan Murdoch



More information about the R-help mailing list