23

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  TRAUTH         0.1193 0.1113     NA       32 0.0764      4      2  07/20/83
14  1983  TRI-COUNTY  TRAUTH         0.1064 0.1064     NA       26 0.0763      6      2  08/03/83
17  1983  TRI-COUNTY  TRAUTH         0.1110 0.1010 0.1010      176 0.0763      7      4  08/08/83
24  1983  TRI-COUNTY  TRAUTH         0.1293 0.1215     NA      452 0.0763      4      0  09/12/83
41  1984  TRI-COUNTY  TRAUTH         0.1325 0.1225     NA      452 0.0740      4      0  06/20/84
45  1984  TRI-COUNTY  TRAUTH         0.1425 0.1325     NA       32 0.0741      4      2  07/17/84
47  1984  TRI-COUNTY  TRAUTH         0.1395 0.1395 0.1250       91 0.0741     14     11  07/16/84

But I want to renumber these such that its 1,2,3,4,etc...

Can someone please help?

joran
  • 169,992
  • 32
  • 429
  • 468
user1684750
  • 297
  • 1
  • 2
  • 7
  • 3
    Not without [considerably more information](http://stackoverflow.com/q/5963269/324364), no. – joran Sep 20 '12 at 03:31

3 Answers3

37

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)
thelatemail
  • 91,185
  • 12
  • 128
  • 188
3

This is the easiest way to do it:

rownames(dataset) = NULL
Josh Levy
  • 31
  • 4
2

Another solution, normally used when binding rows:

dataset <- rbind( dataset , make.rows.names=FALSE )
clemens
  • 16,716
  • 11
  • 50
  • 65
Trisquel
  • 51
  • 2