[R] Memisc package: imported varibles from SPSS have got wrong measurement

David Winsemius dwinsemius at comcast.net
Thu Jul 26 02:35:57 CEST 2012

On Jul 25, 2012, at 9:48 AM, Marion Wenty wrote:

> Dear list members,
> I have got another problem. I imported an SPSS file with the Memisc  
> package
> using the following commands:
> mz <- spss.system.file("myspssfile.sav")
> mz <- subset(mz,select=c(
> bsex,balt,xurb,dtaet,kartab,bgeb,boseit,bgeblan,xnuts2,kausb,xerwstat,
> asbper,asbhh,ajahr,aquartal,bstaat,xwieoft,gew1,apkz,bpkzm,bpkzv))

The memisc package help file for spss.system.file() (actually labeled  
"importers") says that there is an S4 method for "subset" there does  
not seem to be a separate page describing its behavior or values

> Afterwards I checked the measurements of the variables

What does that phrase mean? What code did you actually use?

> and they are all
> right for most of them (e.g. the variable containing the sex of a  
> person is
> "nominal" and the variable containing the year is "interval"). For  
> two of
> the variables the measurement is not o.k, though. They exclusively  
> contain
> numbers in the SPSS file (e.g. the age of a person) - and no NAs -  
> but have
> got the measurement "nominal"!

Hard to say. There is no R storage mode that is called "nominal".  
Perhaps some sort of memisc-specific terminology? Or perhaps something  
in your spss dataset... to which you have not provided access? Or the  
default setting for the spss.system.file access method?  I know that  
the Hmisc package's describe() function will report out a variable as  
though it were categorical if there are only 8 or fewer unique values.

After looking at further help pages and trying the help pages code, I  
am guessing that some of my puzzlement might be answered by reading  
the vignettes, but you can do that yourself.

Here's a hackish guess ... try:

measurement(mz$age_variable) <- "interval"
# where age_variable is the unstated item in that "select" list


David Winsemius, MD

More information about the R-help mailing list