We can try with sprintf
(assuming that row.names in the example are numerical)
sprintf("%08d", df1$row.names)
#[1] "04921103" "00042106" "19562106" "00011102" "03435467"
If it is not numeric, convert to numeric and use sprintf
sprintf("%08d", as.numeric(df1$row.names))
If we meant row.names
as the rownames of the dataset
row.names(df2) <- sprintf("%08d", as.numeric(row.names(df2)))
row.names(df2)
#[1] "04921103" "00042106" "19562106" "00011102" "03435467"
NOTE: No external packages needed.
data
df1 <- structure(list(row.names = c(4921103L, 42106L, 19562106L, 11102L,
3435467L)), .Names = "row.names", class = "data.frame", row.names = c(NA,
-5L))
df2 <- data.frame(v1= 1:5)
row.names(df2) <- c(4921103L, 42106L, 19562106L, 11102L, 3435467L)