Renumbering rows after ordering in R programme

前端 未结 3 1123
半阙折子戏
半阙折子戏 2021-02-18 17:00

I have ordered a set of rows to get this:

2   1983  TRI-COUNTY  TRAUTH         0.1495 0.1395     NA      452 0.0764      4      0  06/02/83
4   1983  TRI-COUNTY          


        
3条回答
  •  野性不改
    2021-02-18 17:35

    Are you just looking for something like this?:

    row.names(datasetname) <- 1:nrow(datasetname)
    

    Alternatively, if the first column in your example data is a variable (say V1) in a dataframe and not the row.names, this will work:

    datasetname$V1 <- 1:nrow(datasetname)
    

提交回复
热议问题