On Thu, 22 Mar 2001, Robert Cunningham wrote:
> Hi there,
>
> Here is my situation:
> > User
> NEWBIE!!!!!
>
> > version
> _
> platform i386-pc-mingw32
> arch x86
> os Win32
> system x86, Win32
> status
> major 1
> minor 2.2
> year 2001
> month 02
> day 26
> language R
>
> I wonder why.
>
> Given this data set
> > names(ants)
> [1] "id" "run" "trap" "spp"
"no"
>
> I can use 'n' as an abbreviation for 'no'
[I suggest that you resist this...see below.]
>
> > sum(ants$n)
> [1] 18087
>
> but below I cannot
>
> > attach(ants)
> > sum(n)
> Error in sum(n) : Object "n" not found
> > sum($n)
> Error: syntax error
>
>
> Am I missing something from the manual?
Names of components are partially matched when accessed by $, or [[ ]].
After attaching a list, the general search mechanism is used, and symbols
are not partially matched.
Beware that using partial matching is regrarded as bad practice, as
changing the list (e.g. adding to it) can break code which relies on this.
--
Brian D. Ripley, ripley at 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-help 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-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._