Iconv: Convert Annotations, and Value Labels between Encodings

Description Usage Arguments Value See Also Examples

View source: R/Iconv.R

Description

This function uses the base package function iconv to translate variable descriptions (a.k.a variable labels) and value labels of item, data.set, and 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Iconv(x,from="",to="",...) 
## S3 method for class 'annotation'
Iconv(x,from="",to="",...) 
## S3 method for class 'data.set'
Iconv(x,from="",to="",...) 
## S3 method for class 'importer'
Iconv(x,from="",to="",...) 
## S3 method for class 'item'
Iconv(x,from="",to="",...) 
## S3 method for class 'value.labels'
Iconv(x,from="",to="",...) 

Arguments

x

an object of which attributes are to be re-encoded.

from

a character string desribing the original encoding

to

a character string desribing the target encoding

...

further arguments, passed to iconv

Value

Iconv returns a copy of its first argument with re-encoded attributes.

See Also

iconv,iconvlist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# 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")

## End(Not run)

memisc documentation built on May 2, 2019, 5:45 p.m.

Related to Iconv in memisc...