[R] problem with attr()

Gardar Johannesson gardar at stat.ohio-state.edu
Wed Nov 27 21:41:02 CET 2002


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list