How do I generate random integers within a specific range in R? I want to generate 100 random integers from an exponential distribution in R, where each integer is between 10 and 50 (hence 10, 11, 12, ..., 49, 50). How can I do this in R?
 A: You can't "cap off" an exponential distribution. If you limit its values to a certain range it stops being an exponential distribution.
Here's a working example with the uniform distribution:
floor(runif(100, min = 10, max = 51))

A: You know the quantiles to which $10$ and $50$ correspond, right? These are given by pexp(10, rate) and pexp(50, rate), respectively. With a rate of $1$, I get quantiles of $0.9999546$ and $\sim 1$, so you want exponential values between those quantiles.
Simulate from a uniform distribution with those values as the endpoints: values <- runif(N, pexp(10, rate), pexp(50, rate)). These will be the exponential quantiles of your simulated data.
Now pass those quantiles through the exponential quantile function: x <- qexp(values, rate) to look up their values.
This should generate exponential-y data that are limited to your range.
As has been noted, however, if you limit your range like this, you no longer have exponential data.
EDIT
Round as Henry describes if you are determined to have integers.
