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 :-/
Cheers,
H.
> sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.0.0
--
Herv? Pag?s
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024
E-mail: hpages at fhcrc.org
Phone: (206) 667-5791
Fax: (206) 667-1319
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
Seemingly Similar Threads
- multiple issues with is.unsorted()
- subsetting by name is very slow when subscript contains a lot of "invalid" names
- error when calling seek() twice on a gzfile connection
- getting corrupted data when using readBin() after seek() on a gzfile connection
- print( , right=TRUE) displays the col numbers on the left