Skip to content
Prev 77832 / 398502 Next

How to get the rowindices without using which?

Hi,

I was wondering if it is possible to get the
rowindices without using the function "which" because
I don't have a restriction criteria. Here's an example
of what I mean:
# take 10 randomly selected instances
iris[sample(1:nrow(iris), 10),]

# output
    Sepal.Length Sepal.Width Petal.Length Petal.Width 
  Species
76           6.6         3.0          4.4         1.4
versicolor
105          6.5         3.0          5.8         2.2 
virginica
131          7.4         2.8          6.1         1.9 
virginica
79           6.0         2.9          4.5         1.5
versicolor
69           6.2         2.2          4.5         1.5
versicolor
42           4.5         2.3          1.3         0.3 
   setosa
25           4.8         3.4          1.9         0.2 
   setosa
129          6.4         2.8          5.6         2.1 
virginica
60           5.2         2.7          3.9         1.4
versicolor
80           5.7         2.6          3.5         1.0
versicolor

What I want to get are their rownumbers: 76, 105, 131,
79, 69, 42, 25, 129, 60, 80.

Thanks in advance,

Martin