| 1 |
\name{charTrans} |
| 2 |
\alias{charTrans} |
| 3 |
\alias{charTrans.character} |
| 4 |
\alias{charTrans.annotation} |
| 5 |
\alias{charTrans.data.set} |
| 6 |
\alias{charTrans.importer} |
| 7 |
\alias{charTrans.item} |
| 8 |
\alias{charTrans.value.labels} |
| 9 |
\encoding{UTF-8} |
| 10 |
|
| 11 |
\title{Character Translation of Aspects of Objects} |
| 12 |
\description{ |
| 13 |
This function uses the base package function \code{\link[base]{chartr}} |
| 14 |
to translate characters in variable descriptions (a.k.a variable labels) and |
| 15 |
value labels of \code{\link{item}}, \code{\link{data.set}}, |
| 16 |
and \code{\link{importer}} objects. |
| 17 |
|
| 18 |
It will be useful when the encoding of an important data set |
| 19 |
cannot be fully identified or if the encoding in the data file |
| 20 |
is incorrect or unknown. |
| 21 |
} |
| 22 |
\usage{ |
| 23 |
|
| 24 |
charTrans(x, old = "", new = "", \dots) |
| 25 |
\method{charTrans}{annotation}(x, old = "", new = "", \dots) |
| 26 |
\method{charTrans}{data.set}(x, old = "", new = "", \dots) |
| 27 |
\method{charTrans}{importer}(x, old = "", new = "", \dots) |
| 28 |
\method{charTrans}{item}(x, old = "", new = "", \dots) |
| 29 |
\method{charTrans}{value.labels}(x, old = "", new = "", \dots) |
| 30 |
|
| 31 |
} |
| 32 |
\arguments{ |
| 33 |
\item{x}{a character vector or an object of which character data or attributes |
| 34 |
character-translated.} |
| 35 |
\item{old}{a string with the characters to be translated.} |
| 36 |
\item{new}{a string with the translated characters.} |
| 37 |
\item{\dots}{further arguments, currently ignored.} |
| 38 |
} |
| 39 |
\value{ |
| 40 |
\code{charTrans} returns a copy of its first argument with character-translated |
| 41 |
character data or attributes. |
| 42 |
} |
| 43 |
\seealso{ |
| 44 |
\code{\link[base]{chartr}} |
| 45 |
} |
| 46 |
\examples{ |
| 47 |
\dontrun{ |
| 48 |
# Locate an SPSS 'portable' file and get info on variables, their labels |
| 49 |
S2601.POR <- spss.portable.file("POR-Files/S2601.POR", encoded = "cp850") |
| 50 |
# 'ß' appears to be correctly coded, but 'ä', 'ö', 'ü' are not, so we need to |
| 51 |
# to some fine-tuning |
| 52 |
S2601.POR <- charTrans(S2601.POR, old="{|}\r", new="äöü ") |
| 53 |
# Now labels etc. are correctly encoded. |
| 54 |
codebook(S2601.POR) |
| 55 |
} |
| 56 |
} |