Renumbering rows after ordering in R programme

前端 未结 3 1137
半阙折子戏
半阙折子戏 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:11

    This is the easiest way to do it:

    rownames(dataset) = NULL
    
    0 讨论(0)
  • 2021-02-18 17:24

    Another solution, normally used when binding rows:

    dataset <- rbind( dataset , make.rows.names=FALSE )
    
    0 讨论(0)
  • 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)
    
    0 讨论(0)
提交回复
热议问题