rdataframeleading-zero

How to remove zeros from zero-left numbers (leading zeros) in a dataframe?


I have this dataframe

df = data.frame(x = c('01','02','03','04','05'))
df

And the objective is to have the output as follows :

  x
1 1
2 2
3 3
4 4
5 5

Solution

  • Use this

    df$x <- as.integer(df$x)