[R] read.spss (package foreign) and character columns
RINNER Heinrich
H.RINNER at tirol.gv.at
Wed Aug 27 18:06:16 CEST 2003
Dear R users!
I am using R Version 1.7.1, Windows XP, package "foreign" (Version: 0.6-1),
SPSS 11.5.1.
There is one thing I noticed with "read.spss", and I'd like to ask if this
is considered to be a feature, or possibly a bug:
When reading character columns, character strings seem to get filled with
blanks at the end.
Simple example:
In SPSS, create a file with one variable called "xchar" of type "A5"
(character of length 5), and 3 values ("a", "ab", "abcde"), save it as
"test.sav".
In R:
> library(foreign)
> test <- read.spss("test.sav", to.data.frame=T)
> test
XCHAR
1 a
2 ab
3 abcde
> levels(test$XCHAR)
[1] "a " "ab " "abcde"
Shouldn't it rather be "a" "ab" "abcde" (no blanks)?
-Heinrich.
More information about the R-help
mailing list