From pdalgd at gmail.com  Wed Apr 24 08:11:08 2013
From: pdalgd at gmail.com (peter dalgaard)
Date: Wed, 24 Apr 2013 08:11:08 +0200
Subject: [Rd] is.vector(as.vector(x, m), m) not always TRUE
In-Reply-To: <51771DDA.3040403@fhcrc.org>
References: <51771DDA.3040403@fhcrc.org>
Message-ID: <6BC93B8B-183D-47BB-9910-C14418B108DE@gmail.com>


On Apr 24, 2013, at 01:48 , Herv? Pag?s wrote:

> In the man page for as.vector() (same as man page for vector()):
> 
>     Writers of methods for ?as.vector? need to take care to follow the
>     conventions of the default method.  In particular
> 
>        ? Argument ?mode? can be ?"any"?, any of the atomic modes,
>          ?"list"?, ?"expression"?, ?"symbol"?, ?"pairlist"? or one of
>          the aliases ?"double"? and ?"name"?.
> 
>        ? The return value should be of the appropriate mode.  For
>          ?mode = "any"? this means an atomic vector or list.
> 
>        ? Attributes should be treated appropriately: in particular
>          when the result is an atomic vector there should be no
>          attributes, not even names.
> 
>        ? ?is.vector(as.vector(x, m), m)? should be true for any mode
>          ?m?, including the default ?"any"?.
> 
> But:
> 
>  > is.vector(as.vector("a", "name"), "name")
>  [1] FALSE
> 
> Mmmh, the default method itself doesn't seem to follow its own
> conventions :-/
> 

Looks like there should be a straightforward fix, since

> is.vector(as.vector("a", "name"), "symbol")
[1] TRUE

so it is just a matter of implementing "name" as synomyous with "symbol".

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] is.vector(as.vector(x, m), m) not always TRUE
peter dalgaard