Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Producing a sequence of numbers in descending order

I want to produce a sequence of numbers in descending order from 1 to 0 by increments of 0.00001. This probably seems super random, but I need to use these tiny decrements as row names for a large database I'm working with.

I initially tried using the seq() function, but got an error telling me that "my sign" was not accepted. I took that to mean that the seq() function can only be used for ascending numerical sequences (is that correct?).

Please advise, thank you!


1 Answers

You need to do add a minus to the by value

seq(from = 1, to = 0, by = -0.00001)
#[1] 1.00000 0.99999 0.99998 0.99997 0.99996 0.99995 ...
like image 96
markus Avatar answered Oct 21 '25 23:10

markus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!