I have a set of postcodes in one column in a large dataset. I want to take out the middle white space, e.g I would like "ABC 123" to be "ABC123". I've tried using str_squish and I can't get it to work. Can someone suggest the correct usage for the code below please or another method - many thanks.
By the way, the reason str_squish() didn’t work is that it’s solving a slightly different problem. It only removes repeated internal whitespace, so it will turn 2+ spaces into 1, but not 1 space into 0. For example (shamelessly lifted from the documentation):
str_squish(" String with trailing, middle, and leading white space\t")
#> [1] "String with trailing, middle, and leading white space"