使用dplyr去掉R列值中的空格

时间:2016-02-12 18:42:54

标签: r dplyr

我有一些列出邮政编码的数据:

   Postcode easting northing
1  AB1 1AA  394251   806376
2  AB1 1AB  394235   806529
3  AB1 1AF  394181   806429
4  AB1 1AG  394251   806376
5  AB1 1AH  394371   806359

我想通过这样做摆脱Postcode列中的所有空格:

library(dplyr)
postcodes %>% mutate(Postcode = gsub(" ", "", Postcode))

但它似乎不适用于我的data.frame。我出错的任何想法?

我可以通过基地R来完成:

  postcodes$Postcode <- gsub(" ", "", postcodes$Postcode)

但想在dplyr中找到解决方案

0 个答案:

没有答案