readstata13 (version 0.9.2)

set.label: Assign Stata Labels to a Variable

Description

Assign value labels from a Stata label set to a variable. If duplicated labels are found, unique labels will be generated according the following scheme: "label_(integer code)". Levels without labels will become <NA>.

Usage

set.label(dat, var.name, lang = NA)

Arguments

dat

data.frame. Data.frame created by read.dta13.

var.name

character. Name of the variable in the data.frame

lang

character. Label language. Default language defined by get.lang is used if NA

Value

Returns a labeled factor

Examples

Run this code
# NOT RUN {
dat <- read.dta13(system.file("extdata/statacar.dta", package="readstata13"),
                  convert.factors=FALSE)

# compare vectors
set.label(dat, "type")
dat$type

# German label
set.label(dat, "type", "de")
# }

Run the code above in your browser using DataLab