0

Most of the data I practice R with is imported from my SPSS files using the haven package. I am trying to reverse code a few columns for scales that go from 1 to 9 (i.e., trying to convert all 1s into 9s, 2s into 8s, etc.) and found another forum describing the psych package. I have tried it on my data and am almost certain my code is correct (and variables properly spelt), but I keep getting an error: requires numeric/complex matrix/vector arguments. I was wondering if this is because the class for the columns in the data file is "haven-labelled" instead of being numeric.

data <- read_spss(Pilot1RAWDATA.sav")
library(psych)
data <- reverse.code(keys = c("soiatt_3", "fematt_3"), items = data, mini = 1, max = 9)
David Nichols
  • 559
  • 3
  • 5
  • why not just calculate `data$soiatt_3 – eli-k Mar 17 '20 at 05:09
  • I probably will end up doing that, but I like looking at new packages and learning about them, and the psych package looked like it could be useful as I do psych research. Although I suppose practicality should be more important, especially if I want to move from academia to data science. Thanks for the alternative! – Vania Rolon Mar 18 '20 at 13:38

0 Answers0