FrameCleaner: A class for cleaning a data frame object

FrameCleanerR Documentation

A class for cleaning a data frame object

Description

This class contains common cleaning routines for data frame objects. The input data frame may be one of data.frame, tibble, or data.table, but the output data frame will be a data.table object. If needed, an object of the original class can be returned by calling the restore() method, which returns a copy of the modified data frame with the original class attribute.

Public fields

df

An object that inherits from data.frame.

col_nms

Column names of the input df.

ptype

A 0-observation slice of the input df.

Methods

Public methods


Method new()

Instantiate a new FrameCleaner object.

Usage
FrameCleaner$new(df)
Arguments
df

An object that inherits from data.frame.

Returns

A new FrameCleaner object.


Method col_nms_trim()

A method for removing leading and trailing white spaces, including space (' '), form feed (\f), line feed (\n), carriage return (\r', horizontal tab (\t), and vertical tab (\v) from column names. The function modifies the df field in-place.

Usage
FrameCleaner$col_nms_trim()
Returns

self


Method restore()

A method for restoring the original class attribute of the input data frame. Note that a copy is returned if the original input df is not a data.table. If the original input df is a data.table, then this method should be a no-op.

Usage
FrameCleaner$restore()
Returns

An object that inherits from data.frame.


YangWu1227/citizenr documentation built on June 18, 2022, 12:17 p.m.