ripley@stats.ox.ac.uk
1999-Dec-04 14:16 UTC
Inconsistent messages with [[ list indexing (PR#359)
R 0.90.0:> Empl <- list(aa=1, b=2, c=3) > Empl[[as.numeric(NA)]]Error in Empl[[as.numeric(NA)]] : subscript out of bounds> Empl[[as.integer(NA)]]Error: attempt to select more than one element> Empl[[as.logical(NA)]]Error: attempt to select more than one element Now, (a) None of those messages is appropriate. (b) At least the first two should be the same. (c) S gives NULL in each case. Is there any reason not to follow S here? If so, I would prefer a specific error message (`NA cannot be used to select a list element'). The usage Empl[[ match("a", names(Empl)) ]] is a very convenient one to defeat partial matching, but the current behaviour of R defeats it. OK, Empl[ match("a", names(Empl)) ] [[1]] works, but this is an ugly hack (and the answer should I believe be the same as [[ ]]). -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._