rm_spl_char: Remove special characters from selected columns

View source: R/clearning-helpers.R

rm_spl_charR Documentation

Remove special characters from selected columns

Description

This function takes a data frame or a tibble object and a vector of columns, removing special characters from the specified columns in the data frame or tibble. To be precise, the function is implemented such that only the character class of numbers and letters in the current locale, i.e., [:alnum:], and periods (".") are retained.

Usage

rm_spl_char(df, var)

Arguments

df

A data frame or tibble.

var

A character vector, with length no greater than length(df), specifying the columns from which special characters are to be removed.

Value

An object of the same type as df with specified columns stripped of their special characters.

See Also

col_nms_rm_spl_char() for removing special characters from columns names.

Examples


# Remove special characters from columns 1 & 2
df_ %>% rm_spl_char(var = c("col_1", "col_2"))

# Remove special characters from all columns
cols <- names(df)
df_ %>% rrm_spl_char(var = cols)


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