Using the new str_remove function in stringr:
str_remove
stringr
id = str_remove(id, "^0+")
Here is a base R option using sub:
sub
id <- sub("^0+", "", id)id[1] "1" "10" "22" "7432"
We can just convert to numeric
numeric
as.numeric(df1$id)[#1] 1 10 22 7432
If we require a character class output, str_replace from stringr can be used
character
str_replace
library(stringr)str_replace(df1$id, "^0+" ,"")#[1] "1" "10" "22" "7432"