Skip to content

set.seed ( ) function

2 messages · Penny Bilton, Joshua Wiley

#
Hi,
On Thu, Apr 21, 2011 at 8:18 PM, Penny Bilton <pennybilton at xnet.co.nz> wrote:
You can use set.seed() to specify a particular seed so that while
pseudo-random numbers are sampled, you can repeat it.  For example:

set.seed(10)
rnorm(10)
set.seed(10)
rnorm(10)
You will never get truly random sampling from a computer algorithm,
but it is darn close and more than adequate in the majority of cases.
123456789 is just a length 1 vector containing the number 123456789,
not 9 separate numbers.

Google will be able to give you a lot of information on pseudo-random
number algorithms as well as the concept of "seeds".  Also see
?set.seed

Cheers,

Josh