[R] SPSS variable lables import

Frank E Harrell Jr f.harrell at vanderbilt.edu
Tue Jun 6 17:55:50 CEST 2006


Thomas Lumley wrote:
> On Tue, 6 Jun 2006, Frank Thomas wrote:
> 
> 
>>Hi,
>>I try to get the variable labels of a SPSS data file into R but don't
>>find this mentioned in the help file for foreign. Is there another way
>>to get them ?
>>BTW: An SPSS variable name is like: VAR001, whereas the variable label
>>might be 'Identification no.'
> 
> 
> mydata <- read.spss("mydata.sav")
> attr(mydata, "variable.labels")
> 
>  	-thomas

Or:

library(Hmisc)
mydata <- spss.get('mydata.sav')
describe(mydata)
contents(mydata)
xYplot( )
etc. use the variable labels attached to individual variables.  You can 
retrieve them also this way:

with(mydata, plot(x, y, xlab=label(x), ylab=label(y)))

Frank Harrell


> 
> Thomas Lumley			Assoc. Professor, Biostatistics
> tlumley at u.washington.edu	University of Washington, Seattle
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University



More information about the R-help mailing list