| 1 |
\name{Iconv} |
| 2 |
\alias{Iconv} |
| 3 |
\alias{Iconv.character} |
| 4 |
\alias{Iconv.annotation} |
| 5 |
\alias{Iconv.data.set} |
| 6 |
\alias{Iconv.importer} |
| 7 |
\alias{Iconv.item} |
| 8 |
\alias{Iconv.value.labels} |
| 9 |
|
| 10 |
\title{Convert Annotations, and Value Labels between Encodings} |
| 11 |
\description{ |
| 12 |
This function uses the base package function \code{\link[base]{iconv}} |
| 13 |
to translate variable descriptions (a.k.a variable labels) and |
| 14 |
value labels of \code{\link{item}}, \code{\link{data.set}}, |
| 15 |
and \code{\link{importer}} objects into a specified encoding. |
| 16 |
|
| 17 |
It will be useful in UTF-8 systems when data file come in some ancient |
| 18 |
encoding like 'Latin-1' as long used by Windows systems. |
| 19 |
} |
| 20 |
\usage{ |
| 21 |
|
| 22 |
Iconv(x,from="",to="",\dots) |
| 23 |
\method{Iconv}{character}(x,from="",to="",\dots) |
| 24 |
\method{Iconv}{annotation}(x,from="",to="",\dots) |
| 25 |
\method{Iconv}{data.set}(x,from="",to="",\dots) |
| 26 |
\method{Iconv}{importer}(x,from="",to="",\dots) |
| 27 |
\method{Iconv}{item}(x,from="",to="",\dots) |
| 28 |
\method{Iconv}{value.labels}(x,from="",to="",\dots) |
| 29 |
|
| 30 |
} |
| 31 |
\arguments{ |
| 32 |
\item{x}{a character vector or an object of which character data or attributes |
| 33 |
are to be re-encoded.} |
| 34 |
\item{from}{a character string describing the original encoding} |
| 35 |
\item{to}{a character string describing the target encoding} |
| 36 |
\item{\dots}{further arguments, passed to \code{\link[base]{iconv}}} |
| 37 |
} |
| 38 |
\value{ |
| 39 |
\code{Iconv} returns a copy of its first argument with re-encoded |
| 40 |
character data or attributes. |
| 41 |
} |
| 42 |
\seealso{ |
| 43 |
\code{\link[base]{iconv}}, \code{\link[base:iconv]{iconvlist}} |
| 44 |
} |
| 45 |
\examples{ |
| 46 |
\dontrun{ |
| 47 |
# Locate an SPSS 'system' file and get info on variables, their labels etc. |
| 48 |
ZA5302 <- spss.system.file("Daten/ZA5302_v6-0-0.sav",to.lower=FALSE) |
| 49 |
|
| 50 |
# Convert labels etc. from 'latin1' to the encoding of the current locale. |
| 51 |
ZA5302 <- Iconv(ZA5302,from="latin1") |
| 52 |
|
| 53 |
# Write out the codebook |
| 54 |
writeLines(as.character(codebook(ZA5302)), |
| 55 |
con="ZA5302-cdbk.txt") |
| 56 |
|
| 57 |
# Write out the description of the varialbes (their 'variable labels') |
| 58 |
writeLines(as.character(description(ZA5302)), |
| 59 |
con="ZA5302-description.txt") |
| 60 |
} |
| 61 |
} |
| 62 |
\keyword{misc} |