convertdf_enc: Convert encoding of character and factor variables in a data...

convertdf_encR Documentation

Convert encoding of character and factor variables in a data frame

Description

Convert encoding of character and factor variables in a data frame

Usage

convertdf_enc(x, from = "", to = "UTF-8", sub = NA, colnames = FALSE)

Arguments

x

An object with the data.frame class (such as data.frame or sf)

from

a character string describing the current encoding.

to

a character string describing the target encoding.

sub

character string. If not NA it is used to replace any non-convertible bytes in the input. (This would normally be a single character, but can be more.) If "byte", the indication is "<xx>" with the hex code of the byte. If "Unicode" and converting from UTF-8, the Unicode point in the form "<U+xxxx>", or if c99, a C99-style escape "\uxxxx". (For points in a ‘supplementary plane’, "\Uxxxxxxxx" is used, with zero-padding)

colnames

Should column names be converted as well?

Details

Encoding strings: all R platforms support "" (for the encoding of the current locale), "latin1" and "UTF-8". See iconv for more information.

Value

The original object, with character variables (and levels of (character) factor variables) converted to the specified encoding.


inbo/n2khab documentation built on Jan. 15, 2025, 9:36 a.m.