Trims the white space on both sides of strings in a character vector and
replaces blank values (""
and " "
) with NA
for all columns in a data
frame that have a character class.
Details
This function should be applied as one of the first steps in the data process to ensure consistent handling of all strings.
Examples
df <- data.frame(one = c(" a", "", " "))
trim_and_make_blanks_NA(df)
#> one
#> 1 a
#> 2 <NA>
#> 3 <NA>