[R] Converting Matrix into List - problem (urgent)
Nidhi Kohli
nidhik at umd.edu
Sun Mar 22 17:26:49 CET 2009
Hi,
I'm trying to convert Matrix into a list format and have written the following code:
path = ("C:/2PL_Alpha_C_2PL_Loading")
setwd(path)
getwd()
congeneric = matrix(rep(NA,36),nrow=6,ncol=6)
conFirst = matrix(rep(NA,36),nrow=6,ncol=6)
conFirstTwenty = rep(NA, 20)
k = 1
#Reading all the Alpha and Congeneric 2PL values into variables
alpha <- read.table("2PLAlphaGenPars_1.dat", header=FALSE)
congeneric <- read.table("C_parameter_estimates_1.dat", header=FALSE)
for (i in 1:6)
{
for (j in 1:6)
{
conFirst[i,j] = as.matrix(congeneric[i,j])
if (k <= 20)
{
conFirstTwenty[k] = as.list(conFirst[i,j])
k = k + 1
}
}
}
In the above program i'm picking up the first 20 values from the Matrix and putting it in a list format. This is what i see now in conFirstTwenty:
[[1]]
[1] "0.520404D+00"
[[2]]
[1] "0.601942D+00"
[[3]]
[1] "0.603340D+00"
[[4]]
[1] "0.655582D+00"
[[5]]
[1] "0.490995D+00"
.........
..........
..........
...........
[[20]]
[1] "0.627368D+00"
I want to remove the Column name and Row name from the above output. Any help on this will be greatly appreciated (I'm open to any other alternative way to convert Matrix into List also)
P.S. I have tried using row.names and col.names in the read.table function however getting error "col.names object not found". I don't know what does this mean
Regards,
Nidhi Kohli
***************************************
Nidhi Kohli, M.Ed.
Doctoral Student
Department of Measurement, Statistics
and Evaluation
University of Maryland
1230 Benjamin Building
College Park, MD 20742-1115
e-mail: nidhik at umd.edu
More information about the R-help
mailing list