I have the following dataset:

```
library(dplyr)
library(gtools)
set.seed(123)
my_data = data.frame(var1 = rnorm(10000,100,100))
```

I am trying to create quantiles (e.g. by 100) for this variable:

```
final = my_data %>%
summarise(quants = quantcut(my_data$var1, 100), count = n())
```

Now, I am trying to add a "rank" variable that will assign the smallest quantile range as 1 ... all the way to the max value:

```
final = my_data %>%
summarise(quants = quantcut(my_data$var1, 100), count = n()) %>%
group_by(quants) %>%
mutate(rank = row_number())
```

The code ran - but all ranks are 1

```
> table(final$rank)
1
100
```

**Can someone please show me how to fix this?**

Thanks!