I am working with an S4 object (I believe) that I need to change. It looks something like this:
str(dataK@K) num [1:226, 1:226] 0.94828 -0.13679 -0.01083 -0.12882
-0.00399 ...
- attr(*, "dimnames")=List of 2 ..$ : chr [1:226] "GT_1" "GT_10" "GT_100" "GT_101" ... ..$ : chr [1:226] "GT_1" "GT_10" "GT_100" "GT_101" ...
>
Now, I need to replace the num-part with an identity matrix and keep the attributes (the chr[1:226] part) as it is. I am totally unfamiliar with S4 slots, and it may be a trivial solution - which I do not know. So I'd be much obliged. Thanks jahn BTW: i've tried dataK@K <- as.matrix(diag(226)) but that takes away the attributes.