[Rd] [foreign] read.spss 'measure' attribute

From: Jeroen Ooms <jeroen.ooms_at_stat.ucla.edu>
Date: Fri, 29 Jul 2011 18:06:40 +0200


In SPSS compatible datafiles, every variable has a property called
'Measure'. This attribute can be observed as the last column in 'variable
view mode' when the dataset is opened in e.g. GNU PSPP. The property is not very important, but is used by many researchers to distinguish between
'Ordinal' and 'Nominal' variables; respectively ordered and unordered
factors in R.

The measure property does not seem to be extracted by the foreign::read.spss function. It would be nice if there would be a way to read this information, and add is as an attribute to every variable.

A very useful feature (at least for me :-) would be to include an option in read.spss that variables which are currently converted to an R factor, will be converted to an ordered.factor when Measure equals 'Ordinal'. Or in pseudocode:

After reading in the spss dataset and converting it to a data.frame: for var in data.frame:

    if ( class ( var ) == "factor" && Measure == "Ordinal" ) {

        class ( var ) <- c( "ordered", "factor" )     }

Here a datafile to play with:

download.file("http://www.stat.ucla.edu/~jeroen/files/1991GS.sav", "1991GS.sav");
mydata <- read.spss("1991GS.sav", to.data.frame=T); sapply(mydata, is.ordered);

Thanks.

        [[alternative HTML version deleted]]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 29 Jul 2011 - 16:11:19 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Jul 2011 - 16:20:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive