*set.seed(1)*

*# rolling a dice three times in a row*

*sample(1:6, 3, replace = T)*

*># 1 4 1*

*set.seed(2)*

*# rolling a dice three times in a row*

*sample(1:6, 3, replace = T)*

## 5 6 6

Hi R community,

I just began practising R with Econometrics and I'm starting with the very basics of probability where I have recently been confused about the function set.seed()

According to my understanding of this function, it works for the reproducibility of random number generation. However, my question is, does set.seed(1) means that the first number among a set of randomly generated numbers will be 1? Because as seen from the results posted above, the first number of my RNG sample was not 2 even though I used set.seed(2).

set.seed(1)

*# rolling a dice three times in a row*

*sample(1:6, 3, replace = T)*

*dice <- sample(1:6, 3, replace = T)*

*mean(dice)*

## 3.3333

Next question, why is the result of the mean (dice) above 3.3333 whereas the result of mean(1:6, 3, replace = T) is 3.5. I thought the function *dice <- sample(1:6, 3, replace = T)* was supposed to assign value to dice. Why are the results generated different?