encodeCharColumns: Encode character columns.

Description Usage Arguments Details Value Examples

View source: R/encodeCharColumns.R

Description

Encode a subset of character columns using base64 encoding.

Usage

1
encodeCharColumns(df, columnNames = NULL)

Arguments

df

A dataframe

columnNames

The columns which are to be encoded. If NULL, all character columns are detected and encoded.

Details

Texual data in dataframes with comman seperators like ',' create problems writing to disk and reading back. This function encodes the a subset of character columns using base64 encoding where the resulting dataframe might be written to disk with ',' separator. The function 'decodeCharCols' decodes the encoded character columns are restores back the actual character columns.

Value

A dataframe

Examples

1
2
3
4
5
6
7
8
iris2 <- iris
iris2$Species <- as.character(iris2$Species)
iris_enc <- encodeCharColumns(iris2)
iris_enc
unique(iris_enc$Species)
iris_dec <- decodeCharColumns(iris_enc, "Species")
iris_dec
all.equal(iris_dec, iris2)

talegari/sidekicks documentation built on Sept. 26, 2018, 4:18 p.m.