On 26/02/2013 10:30, Patrick Burns wrote:
Is it on purpose that `[[` strips the
names when used on an atomic vector?

Yes, and documented! It does when used on a list, so is consistent.

          ‘"[["’ can be used to select
     a single element _dropping_ ‘names’, whereas ‘"["’ keeps them,
     e.g., in ‘c(abc = 123)[1]’.




 > c(a=1, b=2)[1]
a
1
 > c(a=1, b=2)[[1]]
[1] 1


 > sessionInfo()
R Under development (unstable) (2013-02-11 r61902)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base




--
Brian D. Ripley,                  rip...@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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to