problem with attr()
It's a bug in do_attr. Although not documented, this looks for a partial match as well as a full match. *Unfortunately* if it finds two partial matches (as in your example) it gives up and returns NULL. That is correct unless there is an exact match later .... I am about to put a fix in R-patched.
On Wed, 27 Nov 2002, Gardar Johannesson wrote:
I got this wired behaviour of the attr() function using R-1.6.1 on both linux redhat 7.3 (i386) and Solaris 8 (Sparc):
> tmp <- list(id=1) > > attr(tmp,"n.ch") <- 2 > attr(tmp,"n") <- 1 > tmp
$id [1] 1 attr(,"n.ch") [1] 2 attr(,"n") [1] 1
> > attributes(tmp)
$names [1] "id" $n.ch [1] 2 $n [1] 1
> attr(tmp,"names")
[1] "id"
> attr(tmp,"n.ch")
[1] 2
> attr(tmp,"n")
NULL
>
The attr()function doesn't find the 'n' attribute, however, if I don't create the 'n.ch' attribute, it finds it! That is:
> tmp <- list(id=1) > attr(tmp,'n')
NULL
> attr(tmp,'n') <- 1 > attr(tmp,'n')
[1] 1
>
--
_________________________________________________________ Gardar Johannesson Department of Statistics The Ohio State University 304E Cockins Hall, 1958 Neil Ave. Columbus, OH 43210 Email: gardar at stat.ohio-state.edu Tel: (614) 292-1567 Web: www.stat.ohio-state.edu/~gardar Fax: (614) 292-2096 _________________________________________________________ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._