ripley@stats.ox.ac.uk
2002-May-15 07:08 UTC
(PR#1558) [Rd] language: bug or feature: vector-subscript of
On Wed, 15 May 2002 mark.bravington@csiro.au wrote:> Full_Name: Mark Bravington > Version: R1.3.1 & R1.5.0 > OS: Windows 2000 > Submission from: (NULL) (140.79.2.3) > > > R doesn't like the use of subscripts with length > 1, to get into recursive > lists: > > > listio_ list( a=list( b=9, c='hello'), d=1:5) > > listio[[ c( 1, 2)]] > Error: attempt to select more than one element > > > > S is more relaxed: > > test> listio_ list( a=list( b=9, c='hello'), d=1:5) > test> listio[[ c(1,2)]] > [1] "hello" > test> > > The same goes for assignment into recursive lists. > > I find this feature essential, so I eventually wrote the workarounds below. But > I'm sure these are slow and ungainly. > > Could this feature not be added as a primitive?[[ is already a primitive, and nowhere that I can see is it documented that it allows an argument of length 2. So it is neither a bug nor a feature, but a difference from S. If you submit a patch based on the current R-devel sources, we will add it if it checks out. Otherwise, as no one else has ever expressed a need of this feature, it is very unlikely to get implemented. R is not a clone of S, and has the features it has because the workers had need of them. Please do _not_ use "foo_ ". It is not a meaningful grouping, and it is planned to deprecate `_' in R shortly. -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._