malcolm
2012-Mar-05 04:46 UTC
[R] how I can explore the variable names in my covariance matrix?
Hi all! I am writing because I have a small problem I have a matrix with different variables names I made a function to compute the covariance matrix for my first matrix, but the variables names changed to numbers e.s [,1]........ how I can explore the variable names in my covariance matrix???? thanks for every one want to help -- View this message in context: http://r.789695.n4.nabble.com/how-I-can-explore-the-variable-names-in-my-covariance-matrix-tp4445149p4445149.html Sent from the R help mailing list archive at Nabble.com.
branch.lizard
2012-Mar-05 04:50 UTC
[R] how I can explore the variable names in my covariance matrix?
Can you provide a sample of code for us? -- View this message in context: http://r.789695.n4.nabble.com/how-I-can-explore-the-variable-names-in-my-covariance-matrix-tp4445149p4445156.html Sent from the R help mailing list archive at Nabble.com.
malcolm
2012-Mar-05 05:14 UTC
[R] how I can explore the variable names in my covariance matrix?
QQ<-diag(7)
for (j in 1:7){
for (k in 1:7){
sum=0
for (i in 1:50){
sum=sum+(Y[i,j]-mean(Y[,j]))*(Y[i,k]-mean(Y[,k]))
}
QQ[j,k]=sum/49
}
}
round(QQ,2)
this is the function I made
--
View this message in context:
http://r.789695.n4.nabble.com/how-I-can-explore-the-variable-names-in-my-covariance-matrix-tp4445149p4445180.html
Sent from the R help mailing list archive at Nabble.com.
branch.lizard
2012-Mar-06 06:05 UTC
[R] how I can explore the variable names in my covariance matrix?
I would do:
QQ.frame <- data.frame(round(QQ,2))
name(QQ.Frame) <- paste("foo",seq(1:7))
foo 1 foo 2 foo 3 foo 4 foo 5 foo 6 foo 7
1 1 0 0 0 0 0 0
2 0 1 0 0 0 0 0
3 0 0 1 0 0 0 0
4 0 0 0 1 0 0 0
5 0 0 0 0 1 0 0
6 0 0 0 0 0 1 0
7 0 0 0 0 0 0 1
sorry my indent got a little off.
Is this what you are looking for?
--
View this message in context:
http://r.789695.n4.nabble.com/how-I-can-explore-the-variable-names-in-my-covariance-matrix-tp4445149p4448858.html
Sent from the R help mailing list archive at Nabble.com.