How to use str_squish on a column of postcodes

Ah, the delights of our UK postcode system:

Try this:

df %>% 
  mutate(Postcode = str_replace(Postcode, " ", ""))
5 Likes