Get Origin Code Numbers for Factors
Recreates the code numbers of a factor as stored in the Stata dataset.
get.origin.codes(x, label.table)
x |
factor. Factor to obtain code for |
label.table |
table. Table with factor levels obtained by
|
While converting numeric variables into factors, the original code
numbers are lost. This function reconstructs the codes from the attribute
label.table.
Returns an integer with original codes
Jan Marvin Garbuszus jan.garbuszus@ruhr-uni-bochum.de
Sebastian Jeworutzki sebastian.jeworutzki@ruhr-uni-bochum.de
dat <- read.dta13(system.file("extdata/statacar.dta", package="readstata13"))
labname <- get.label.name(dat,"type")
labtab <- get.label(dat, labname)
# comparsion
get.origin.codes(dat$type, labtab)
as.integer(dat$type)Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.