I have created an object in R that contains several attributes. How can I easily access them?
I can do:
attr(x, attributeName)
or:
Don't use attributes for your object, use a list:
myobj <- structure(list(a = 1, b = 2), class = "myclass")
print.myclass <- function(x, ...) cat("A: ", x$a, " B: ", x$b, "\n", sep = "")
myobj
Of course, this might not work if you're extending an existing object (e.g. vector), but in my experience it's a generally better way to build objects.