testdf = data.frame(name=c("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o"), score = c(11,15,46,32,22,68,89,35,54,12,44,3,1,88,6))
testdf$rank<-rank(testdf$score)
when using the rank function in R it doesnt include leading zeros-- it ranks
1
2
3
...
10
11
12
but that means sometimes when it sorts it sorts as: 1, 10, 11, 12...2, 21, 22, 23...3, 31, 32, 33. instead of 1, 2, 3, 4.
is there a way to include the leading zero with the rank function such that the output is 01, 02, 03, 04, etc
the complete example that i am using is not reproducible on here. i am using the rank function then combining it with another column to create a rank and total (converts to character). See this image of the output
you will see that it is ordering by 1, 10, 11...2, 20, 21, etc. rather than 1,2,3,4...which is why i was hoping to include leading zeros because when i combine the columns it is no longer a numeric vector