Random Variables
Random numbers
rfor random numnerdfor densitypfor cumulative distributionqfor quantile function
More about functions is here.
The random numbers are not actually random. You can reproduce them by setting seed.
> set.seed(1)
> rnorm(5)
[1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078
> set.seed(1)
> rnorm(5)
[1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078Sampling
> set.seed(1)
> sample(1:10, 4)
[1] 3 4 5 7
> sample(letters, 4)
[1] "f" "w" "y" "p"
> sample(letters, replace=T)
[1] "q" "b" "f" "e" "r" "j" "u" "m" "s" "z" "j" "u" "y" "f" "q" "d" "g" "k" "a" "j" "w" "i" "m" "p" "m" "e"With
replaceset to true, the values can repeate.
Last updated
Was this helpful?