[Rd] is.vector(as.vector(x, m), m) not always TRUE
peter dalgaard
pdalgd at gmail.com
Wed Apr 24 08:11:08 CEST 2013
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
More information about the R-devel
mailing list