Reset the row names of a data frame x to 1:nrow(x) by setting the
row.names
attribute to NULL
.
Examples
persons <- data.frame(id = c(1, 2, 3), name = c("Peter", "Paul", "Mary"))
persons.ordered <- persons[order(persons$name), ]
# Original row names
persons.ordered
#> id name
#> 3 3 Mary
#> 2 2 Paul
#> 1 1 Peter
# Reset row names
resetRowNames(persons.ordered)
#> id name
#> 1 3 Mary
#> 2 2 Paul
#> 3 1 Peter