File: Iconv.Rd

package info (click to toggle)
r-cran-memisc 0.99.31.8.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,136 kB
  • sloc: ansic: 5,117; makefile: 2
file content (62 lines) | stat: -rw-r--r-- 2,063 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
\name{Iconv}
\alias{Iconv}
\alias{Iconv.character}
\alias{Iconv.annotation}
\alias{Iconv.data.set}
\alias{Iconv.importer}
\alias{Iconv.item}
\alias{Iconv.value.labels}

\title{Convert Annotations, and Value Labels between Encodings}
\description{
  This function uses the base package function \code{\link[base]{iconv}}
  to translate variable descriptions (a.k.a variable labels) and
  value labels of \code{\link{item}}, \code{\link{data.set}},
  and \code{\link{importer}} objects into a specified encoding.
  
  It will be useful in UTF-8 systems when data file come in some ancient
  encoding like 'Latin-1' as long used by Windows systems.
  }
\usage{

Iconv(x,from="",to="",\dots) 
\method{Iconv}{character}(x,from="",to="",\dots) 
\method{Iconv}{annotation}(x,from="",to="",\dots) 
\method{Iconv}{data.set}(x,from="",to="",\dots) 
\method{Iconv}{importer}(x,from="",to="",\dots) 
\method{Iconv}{item}(x,from="",to="",\dots) 
\method{Iconv}{value.labels}(x,from="",to="",\dots) 

}
\arguments{
  \item{x}{a character vector or an object of which character data or attributes 
    are to be re-encoded.}
  \item{from}{a character string describing the original encoding}
  \item{to}{a character string describing the target encoding}
  \item{\dots}{further arguments, passed to \code{\link[base]{iconv}}}
}
\value{
  \code{Iconv} returns a copy of its first argument with re-encoded 
  character data or attributes.
}
\seealso{
  \code{\link[base]{iconv}}, \code{\link[base:iconv]{iconvlist}}
}
\examples{
\dontrun{
# Locate an SPSS 'system' file and get info on variables, their labels etc.
ZA5302 <- spss.system.file("Daten/ZA5302_v6-0-0.sav",to.lower=FALSE)

# Convert labels etc. from 'latin1' to the encoding of the current locale.
ZA5302 <- Iconv(ZA5302,from="latin1")

# Write out the codebook
writeLines(as.character(codebook(ZA5302)),
           con="ZA5302-cdbk.txt")

# Write out the description of the varialbes (their 'variable labels')
writeLines(as.character(description(ZA5302)),
            con="ZA5302-description.txt")
}
}
\keyword{misc}