clean_character_columns: Clean character columns

View source: R/misc.R

clean_character_columnsR Documentation

Clean character columns

Description

Removes leading and trailing whitespace from all character columns in a data frame using trimws.

Usage

clean_character_columns(df)

Arguments

df

A data frame or tibble containing character columns to be cleaned

Details

The function uses dplyr::across to apply trimws to all columns that are of type character. The original data frame structure is preserved, only the content of character columns is modified.

Value

A data frame of the same structure as the input, but with whitespace removed from all character columns

Examples

df <- data.frame(
  name = c(" John ", "Jane  ", "  Bob"),
  age = c(25, 30, 35),
  city = c("New York ", " London", " Paris ")
)
clean_df <- clean_character_columns(df)


MoTrPAC/MotrpacBicQC documentation built on April 11, 2025, 7:51 p.m.