File: get.origin.codes.Rd

package info (click to toggle)
r-cran-readstata13 0.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 804 kB
  • sloc: cpp: 1,770; ansic: 278; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tools.R
\name{get.origin.codes}
\alias{get.origin.codes}
\title{Get Origin Code Numbers for Factors}
\usage{
get.origin.codes(x, label.table)
}
\arguments{
\item{x}{\emph{factor.} Factor to obtain code for}

\item{label.table}{\emph{table.} Table with factor levels obtained by
\code{\link{get.label}}.}
}
\value{
Returns an integer with original codes
}
\description{
Recreates the code numbers of a factor as stored in the Stata dataset.
}
\details{
While converting numeric variables into factors, the original code
 numbers are lost. This function reconstructs the codes from the attribute
 \code{label.table}.
}
\examples{
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)
}
\author{
Jan Marvin Garbuszus \email{jan.garbuszus@ruhr-uni-bochum.de}

Sebastian Jeworutzki \email{sebastian.jeworutzki@ruhr-uni-bochum.de}
}