1
vote
$\begingroup$

R and stat noob here. I have been playing with Jeromy Anglim's code in his blog post here. However, my items$variable has some missing values. I tried using the distractor.analysis function from the CTT package with

distractor.analysis(cases[,items$variable], items$correct)

I get the error

Error : missing values and NaN ’s not allowed if ’na .rm ’ is FALSE

Is there a work-around for using distractor.analysis for data with missing responses or is there a better way to perform distractor analysis in R?

$\endgroup$

2 Answers 2

3
votes
$\begingroup$

While uploading the .csv or .xlsx file into R console, keep all the cells containing NA just blank. It would work fine for 'distractor analysis' under CTT Library.

Further, if the missing cells would be filled up by X, then also the distractor.analysis() function under CTT library would work. Hence, the output would be prettier and the row of 'number of candidates who have not attempted the item' would be assigned by X.

It would be wiser to denote all the missing cells by X. That is a find/replace task in that Excel file only. :)

$\endgroup$
1
vote
$\begingroup$

You can remove rows which have NaN values from your response matrix like this:

distractor.analysis(na.omit(cases[,items$variable]), items$correct)

Alternatively, you can assign a different value to the NaN cells in your data.frame like this. This way, you can still use your full dataset and also analyse missing values, if you wish.

$\endgroup$
3
  • $\begingroup$ These two topics seem to be linked, which may be helpful for others to know about in the future: stats.stackexchange.com/questions/144470/… $\endgroup$ Apr 2, 2015 at 2:24
  • $\begingroup$ Hi @DouglasDeRizzoMeneghetti, thanks. I totally forgot I asked this question here. I have since studied subsetting in R and your solution was exactly how I did it. I should have answered my own question but I forgot I even asked it here. But I am amazed at how long it took to answer this question. Thank you. $\endgroup$
    – hpesoj626
    Apr 3, 2015 at 2:56
  • $\begingroup$ It was a coincidence I had to do just that a few days ago, using the very same package. I found this question when searching the site for something similar, which @philchalmers taught me how to do two comments up. $\endgroup$ Apr 3, 2015 at 7:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.