Skip to contents

This function removes special characters from a specified column in a dataframe. It also adds a period after 'NO' if it is a whole word and not already followed by a period.

Usage

remove_spec_char_v1(data, column, keep_parenthesis = TRUE)

Arguments

data

dataframe. The dataframe to modify.

column

character. The name of the column to modify.

keep_parenthesis

logical. If TRUE, parenthesis are kept in the column. If FALSE, parenthesis are removed. Default is TRUE.

Value

dataframe. The modified dataframe.

Examples

data <- data.frame(x = c("NO", "YES (maybe)", "NO (definitely)"))
remove_spec_char_v1(data, "x", FALSE)
#>                 x
#> 1             NO.
#> 2      YES -MAYBE
#> 3 NO. -DEFINITELY