在 R 中使用 stringr 删除前导 0 [英] remove leading 0s with stringr in R

查看:27
本文介绍了在 R 中使用 stringr 删除前导 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下数据

id
00001
00010
00022
07432

我想删除前导的 0 以便数据如下

I would like to remove the leading 0s so the data would like like the following

id
1
10
22
7432

推荐答案

stringr 中使用新的 str_remove 函数:

Using the new str_remove function in stringr:

id = str_remove(id, "^0+")

这篇关于在 R 中使用 stringr 删除前导 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆