[R] Using SPSS Labels
Andrew Choens
andy.choens at gmail.com
Wed Dec 24 05:19:13 CET 2008
I am trying to import a SPSS.sav file into R. The attached file is not
technically the file I am trying to import, but does replicate my
problem. The actual file is much too large to attach. No matter what I
do, I can not get R (base or Hmisc) to apply the value labels in
the .sav file to the dataframe created in R. Here's the code that I am
using.
maine <- spss.get("test.sav")
# or
maine2 <- read.spss("test.sav", read.value.labels=TRUE)
When I try to import the file, the value labels are not assigned to the
rows. This is what I get.
ID GENDER
1 1 1
2 2 2
3 3 1
4 4 2
5 5 1
6 6 1
7 7 1
8 8 2
9 9 2
10 10 1
11 11 3
In the .sav file, 1 = Men 2 = Women 3 = user assigned missing.
The variable values are attached as a value.labels attribute. If I
remove row # 11 (gender = 3), I can import the file as I expect.
ID GENDER
1 1 Men
2 2 Women
3 3 Men
4 4 Women
5 5 Men
6 6 Men
7 7 Men
8 8 Women
9 9 Women
10 10 Men
Given all of this: How can I import a .sav file with user assigned
missing values correctly.
If this is not possible, what is the best way to use the value.labels
attribute when I make a table with table(Gender).
Thanks.
--
Insert something humorous here. :-)
More information about the R-help
mailing list