Arguments

Arguments

Watch this video:

args()

rnorm() is a function that generates random variables from a normal distribution. Find the arguments of rnorm() using the args() function.

args(rnorm)

Good job! n specifies the number of random normal variables to generate. mean and sd describe the distribution to generate the random values with.

Optional arguments

Which arguments of rnorm() are not optional?




rnorm() 1

Use rnrom() to generate 100 random normal values with a mean of 100 and a standard deviation of 15.

rnorm(100, mean = 100, sd = 15)

rnorm() 2

Can you spot the error in the code below? Fix the code and then re-run it.

Hint: In math, \(\mu\) (mu, pronounced “mew” or “moo”) is a Greek letter that stands for the mean of a distribution.

rnorm(100, mean = 100, sd = 15)

Next topic