varlabels: varlabels: extract and restore SPSS variable labels

Description Usage Arguments Details Value Examples

View source: R/haven.R

Description

Extract SPSS variable labels from a data frame read with read_sav in the 'haven' package.

Usage

1

Arguments

data

a data frame, usually read with read_sav.

Details

Many manipulations of data frames in R lose the label attribute that holds SPSS variable labels. 'varlab' and 'varlab<-' allow the variable labels to be extracted and later restored.

Value

a named list of variable labels

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
library(haven)
dat <- read_sav("SPSSfile.sav")
varlabs <- varlabels(dat)
dat <- toR(dat)
# work with dat in R
varlabels(dat) <- varlabs
write_sav(dat, "OUT.sav") # should have variable labels

## End(Not run) 

gmonette/HG documentation built on May 17, 2019, 7:25 a.m.