[Rd] @ accesses attributes, not just formal slots ?

Parlamis Franklin fparlamis at mac.com
Thu May 11 20:53:56 CEST 2006


Using the '@' operator, I am able to extract a 'names' attribute  
assigned to a formal object.
However, I can not use the replacement form ('@<-') to assign that  
attribute.

 > setClass("foo", representation("numeric"))
[1] "foo"
 > (new("foo", 1:4)->a)
An object of class “foo”
[1] 1 2 3 4
 > names(a) <- LETTERS[1:4]
 > a at names
[1] "A" "B" "C" "D"
 > a at names <- LETTERS[5:8]
Error in checkSlotAssignment(object, name, value) :
	"names" is not a slot in class "foo"

I don't know that this asymmetry will ever cause a problem, but I  
just wanted to note it because it appears from the help pages
'slot {methods}'  and 'slotOp {base}' that the '@' operator is only  
intended to provide access to defined slots.

I am still on R 2.2.1.



More information about the R-devel mailing list