Last active
August 7, 2018 13:38
-
-
Save damianooldoni/5da5ea4685a82bcedcc59d5e8384d83b to your computer and use it in GitHub Desktop.
Removes whitespace from start, end and repeated whitespaces inside all dataframe.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(stringr) | |
df <- data.frame(a = c(" aZe aze s", "wxc s aze "), | |
b = c(" 12 12 ", "34e e4 "), | |
stringsAsFactors = FALSE) | |
df <- df %>% | |
rowwise() %>% | |
mutate_all(funs(str_squish(.))) %>% | |
ungroup() | |
df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment