0

Does anyone have any idea why when I recode the data using the psych package my structure changes? How can I keep it the same? (I have tried quite a few things I omitted so the output was cleaner) I believe this change is responsible for the second itemplot x axis being incorrect (at the end of the code below)

> BIG5<-read.csv("BIG5.csv")                ##READ IN THE DATA
> ext<-BIG5[c(8:17)]                    ##SELECT ITEMS TO BE ANALYZED
> library(psych)                        ##WE WILL HAVE TO USE THE PSYCH PACKAGE TO RECODE
> keys<-c(1,-1,1,-1,1,-1,1,-1,1,-1)         ##-1 MEANS REVERSE CODE
> ext_rev<-reverse.code(keys,ext,mini=0,maxi=5)     ##USE THE KEY TO REVERSE CODE AND REPLACE EXT WITH THIS ONE
> library(CTT)
> str(ext)
'data.frame':   19719 obs. of  10 variables:
 $ E1 : int  4 2 5 2 3 1 5 4 3 1 ...
 $ E2 : int  2 2 1 5 1 5 1 3 1 4 ...
 $ E3 : int  5 3 1 2 3 2 5 5 5 2 ...
 $ E4 : int  2 3 4 4 3 4 1 3 1 5 ...
 $ E5 : int  5 3 5 3 3 1 5 5 5 2 ...
 $ E6 : int  1 3 1 4 1 3 1 1 1 4 ...
 $ E7 : int  4 1 1 3 3 2 5 4 5 1 ...
 $ E8 : int  3 5 5 4 1 4 4 3 2 4 ...
 $ E9 : int  5 1 5 4 3 1 4 4 5 1 ...
 $ E10: int  1 5 1 5 5 5 1 3 3 5 ...
> str(ext_rev)
 num [1:19719, 1:10] 4 2 5 2 3 1 5 4 3 1 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:10] "E1" "E2-" "E3" "E4-" ...
> extscores<-score(ext,output.scored=TRUE)
Warning message:
In score(ext, output.scored = TRUE) :
  No key provided, assuming pre-scored data.
> extscores_rev<-score(ext_rev,output.scored=TRUE)
Warning message:
In score(ext_rev, output.scored = TRUE) :
  No key provided, assuming pre-scored data.
> str(extscores)
List of 2
 $ score : Named num [1:19719] 32 28 29 36 26 28 32 35 31 29 ...
  ..- attr(*, "names")= chr [1:19719] "P1" "P2" "P3" "P4" ...
 $ scored: int [1:19719, 1:10] 4 2 5 2 3 1 5 4 3 1 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : NULL
  .. ..$ : chr [1:10] "E1" "E2" "E3" "E4" ...
> str(extscores_rev)
List of 2
 $ score : Named num [1:19719] 39 17 30 17 29 11 41 34 40 10 ...
  ..- attr(*, "names")= chr [1:19719] "P1" "P2" "P3" "P4" ...
 $ scored: num [1:19719, 1:10] 4 2 5 2 3 1 5 4 3 1 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : NULL
  .. ..$ : chr [1:10] "E1" "E2-" "E3" "E4-" ...
> cttICC(extscores$score,extscores$scored[,1])      ##ITEMPLOT WORKS
> cttICC(extscores_rev$score,extscores_rev$scored[,1])      ##ITEMPLOT FAILS

I am apparently having issues linking images, but the x axis is radically different on the failed itemplot, and the values are condensed into representation on a single point. (which all appears consistent with the values being read in incorrectly)

Jaap
  • 81,064
  • 34
  • 182
  • 193
Rilcon42
  • 9,584
  • 18
  • 83
  • 167
  • See [how to create a reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). The code you've shared does not make it easy to recreate the problem which makes it difficult to help you. – MrFlick Feb 09 '16 at 04:25
  • My apologies, but I am unable to recreate an example for this issue- If I knew how to do that I believe I could solve the issue myself. – Rilcon42 Feb 09 '16 at 04:37
  • after trying a few more things, I discovered that if I read in 1200 rows or less it works perfectly.... – Rilcon42 Feb 09 '16 at 05:13

0 Answers0