Hi there,
I'm reasonably new to R and having some difficulty importing an SPSS file the way I would like. I first tried using the haven package and the read_sav()
function. This was able to import my file successfully. I wanted to keep the variable and value labels just as they were saved in the SPSS file, so i used as_factor()
which retained these labels. But then when I went to create simple frequency tables using the count()
function, the labels did not appear in the output (see screenshot).
So I then tried the foreign package instead using the following code to import the file:
df <- ("./folder/filename.sav",
to.data.frame = TRUE,
use.value.labels = TRUE)
But this gave me an error message - error reading system-file header
. I've done a bit of googling and have been unable to find what the issue is. I've heard that haven is the better package so am happy to stick with that one, but still can't figure out why my frequency table isn't giving the proper labels (e.g. under 16 etc.)
Thanks in advance