[R] Print specific matrix value???

Nidhi Kohli nidhik at umd.edu
Sat Jan 10 17:15:00 CET 2009


Hello All,

I'm trying to print specific row and column for Observed_Scores matrix, however, when I execute the command "Observed_Scores[1,1]", I get the message "Error in Observed_Scores[1, 1] : incorrect number of dimensions". Could you please help and let me know where is the mistake? Here is my program:


library(ltm)
library(psych)

# Settting the working directory path to C:/NCME

path="C:/NCME"
setwd(path)

#IRT Data Simulation Routine#

n.exams = 500   #Sets number of examinees to be generated#
n.items = 20     #Sets number of items to be generated#

#The following intialize empty (NA) vectors or matrices#
beta.values = rep(NA,n.items)
resp.prob = matrix(rep(NA,n.exams*n.items),nrow=n.exams,ncol=n.items)
Observed_Scores = matrix(rep(NA,n.exams*n.items),nrow=n.exams,ncol=n.items)


#filling item parameters into beta.values
beta.values = runif(n.items,-2,2)

#Calculating Threshold
thresh.values = .5 * beta.values


#for (i in 1:10)
#{

#Using the function to generate the data
GenData <- congeneric.sim(N=500, loads = rep(.5,20), err=NULL, short = FALSE)
Observed_Scores = GenData[1]

Regards
Nidhi Kohli




More information about the R-help mailing list