I am very new to R and am not sure about the proper language when referring to datamembers and attributes of an object. I have an object-oriented programming language background in Java so I am probably referring to datamembers/attributes in a Java set of mind. Anyway, suppose I have a matrix matClust1
and I have done the following:
ids = vector()
for(i in 1:size) #size is the number of rows in matClust1
{
ids = c(ids, "exp")
}
attr(matClust1, "clustID") <- ids
I think of the above as setting an attribute/datamember of each row vector in matClust1
to "exp"
. This is because ids
is created to have as many entries as there are rows in matClust1
. So, I would like to be able to access this attribute/datamember by code like the following:
matClust1.clustID[2] #get the clustID of row vector in matClust1
Apparently the .
operator does not do this nor does the $
operator.
- How can I achieve this functionality in R?
EDIT: I already have the attribute set for rownames
and what I am really looking for is another variable to work like rownames
.