[R] Print specific matrix value???
Stephan Kolassa
Stephan.Kolassa at gmx.de
Sat Jan 10 18:16:53 CET 2009
Hi Nidhi,
in your very last line, you set
Observed_Scores = GenData[1]
After that, Observed_Scores is not a matrix any more, but a list with a
single entry Observed_Scores$model, which is in fact a data.frame, but
with different dimensions than you initially set Observed_Scores to.
HTH,
Stephan
Nidhi Kohli schrieb:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list