Answers for "R random number"

R
2

generate numbers in distribution r

> runif(1)    # generates 1 random number
[1] 0.3984754
> runif(3)    # generates 3 random number
[1] 0.8090284 0.1797232 0.6803607
> runif(3, min=5, max=10)    # define the range between 5 and 10
[1] 7.099781 8.355461 5.173133
Posted by: Guest on September-09-2020
0

R random number

#returns one decimal number between 5 and 7.5
#first argument is the number of numbers to generate
#second and third are the lower and upper limits
x = runif(1, 5.0, 7.5)
Posted by: Guest on September-12-2021
0

generate numbers in distribution r

> rnorm(1)    # generates 1 random number
[1] 1.072712
> rnorm(3)    # generates 3 random number
[1] -1.1383656  0.2016713 -0.4602043
> rnorm(3, mean=10, sd=2)    # provide our own mean and standard deviation
[1]  9.856933  9.024286 10.822507
Posted by: Guest on September-09-2020

Browse Popular Code Answers by Language