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

View source: R/convertdf_enc.R

convertdf_encR Documentation

Convert encoding of character and factor variables in a dataframe

Description

Convert encoding of character and factor variables in a dataframe

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".

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.

See Also

Other Data_handling_utilities: csv_to_sqlite(), df_factors_to_char()


inbo/inborutils documentation built on Nov. 23, 2023, 4:42 a.m.