powered by
Remove Leading/Trailing Whitespace
clean_whitespace(x, ...)# S4 method for data.frame clean_whitespace(x, which = c("both", "left", "right"), squish = TRUE)# S4 method for matrix clean_whitespace(x, which = c("both", "left", "right"), squish = TRUE)
# S4 method for data.frame clean_whitespace(x, which = c("both", "left", "right"), squish = TRUE)
# S4 method for matrix clean_whitespace(x, which = c("both", "left", "right"), squish = TRUE)
An R object (should be a matrix or a data.frame).
matrix
data.frame
Currently not used.
A character string specifying whether to remove both leading and trailing whitespace (default), or only leading ("left") or trailing ("right").
character
both
left
right
A logical scalar: should all internal whitespace be replaced with a single space?
logical
N. Frerebeau
trimws()
Other data cleaning tools: remove_Inf(), remove_NA(), remove_constant(), remove_empty(), remove_zero(), replace_Inf(), replace_NA(), replace_empty(), replace_zero()
remove_Inf()
remove_NA()
remove_constant()
remove_empty()
remove_zero()
replace_Inf()
replace_NA()
replace_empty()
replace_zero()
x <- data.frame( A = c(" Both ", " Left", "Right "), B = 1:3 ) clean_whitespace(x, which = "both") clean_whitespace(x, which = "left") clean_whitespace(x, which = "right")
Run the code above in your browser using DataLab