Can I suggest that vector() has an additional names argument? This would
make it more comparable with matrix() and array(). I frequently find
myself doing
fred <- vector("list", length(happy))
names(fred) <- names(happy)
when I would rather be doing
fred <- vector("list", length(happy), names = names(happy))
Just a thought. Cheers, Jonathan.
Jonathan Rougier Science Laboratories
Department of Mathematical Sciences South Road
University of Durham Durham DH1 3LE
"[B]egin upon the precept ... that the things we see are to be
weighed in the scale with what we know" (Meredith, 1879, The Egoist)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To:
r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
You might think about using structure()
fred <- structure(vector("list", length(happy)), names =
names(happy))
and in fact you can add as many attributes as you like. This seems a better
plan than tweaking vector() (where do you stop?) and maintains consistency
with S3 at this low level.
It must be said, though, this natural and innocent looking idiom that I once
used quite a lot in S3 code had nasty consequences in going from S3 to S4,
(as BDR frequently reminds me!)
Bill V.
-----Original Message-----
From: Jonathan Rougier [mailto:J.C.Rougier@durham.ac.uk]
Sent: Friday, July 16, 1999 11:13 PM
To: r-devel@stat.math.ethz.ch
Subject: vector()
Can I suggest that vector() has an additional names argument? This would
make it more comparable with matrix() and array(). I frequently find
myself doing
fred <- vector("list", length(happy))
names(fred) <- names(happy)
when I would rather be doing
fred <- vector("list", length(happy), names = names(happy))
Just a thought. Cheers, Jonathan.
Jonathan Rougier Science Laboratories
Department of Mathematical Sciences South Road
University of Durham Durham DH1 3LE
"[B]egin upon the precept ... that the things we see are to be
weighed in the scale with what we know" (Meredith, 1879, The Egoist)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To:
r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To:
r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 19 Jul 1999, Venables, Bill (CMIS, Cleveland) wrote:> You might think about using structure() > > fred <- structure(vector("list", length(happy)), names = names(happy)) > > and in fact you can add as many attributes as you like. This seems a better > plan than tweaking vector() (where do you stop?) and maintains consistency > with S3 at this low level. > > It must be said, though, this natural and innocent looking idiom that I once > used quite a lot in S3 code had nasty consequences in going from S3 to S4, > (as BDR frequently reminds me!)(When used for setting classes instead of class<-, that is.) -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._