I want to generate some random probability values (values between 0 and 1) in R. Which R function should I use for it?

+2 votes

R function **runif()** generates random numbers from a uniform distribution. You can specify 0 as min and 1 as max to get values between 0 and 1.

Here is an example:

> runif(n=10, min = 0, max = 1)

[1] 0.1209878 0.5843316 0.6590292 0.8450934 0.5096714 0.4319844 0.4592134 0.2865568 0.3900819 0.3433897