【发布时间】:2014-06-25 15:45:45
【问题描述】:
我有一个带有字母数字字符的字符向量 d
d <- c("012309 template", "separate 00340", "00045", "890 098", "3405 garage", "matter00908")
d
[1] "012309 template" "separate 00340" "00045" "890 098" "3405 garage" "matter00908"
如何从 R 中的所有数字中删除前导零?
as.numeric 将仅删除数字或整数向量中的所有前导零。我试过gsub 和regex,但没有得到想要的结果。
预期的输出如下
out <- c("12309 template", "seperate 340", "45", "890 98", "3405 garage", "matter908")
out
[1] "12309 template" "seperate 340" "45" "890 98" "3405 garage" "matter908"
【问题讨论】:
标签: regex string r character gsub