replace index of levels instead of a dataframe column in R code example Example: how to change the index of a dataframe in r rownames(dfr) <- 1:nrow(dfr)