I want to generate 10000 integer random numbers between 0 and 10^12. Usually, the code would look like this:
x <- sample(0:1000000000000,10000,replace=T)
The package extraDistr provides a range of additional probability distributions to sample from, including a discrete uniform distribution.
Random sampling with function rdunif works like other stats random sampling functions included with R like runif, and avoids needing to round as in other solutions:
> library("extraDistr")
> rdunif(n = 10000, min = 0, max = 10^12)
[1] 699559531175 881392957410 315869810758 941600866616
[5] 906084092567 681591022527 514061764115 122652820777
[9] 583204373950 517842726316 741211620393 422150962055 ...