Why should I use set.seed function() in R?

0 votes
Apr 23, 2018 in Data Analytics by shams
• 3,580 points
23 views

1 answer to this question.

0 votes
set.seed(seed)
Set the seed of R‘s random number generator, which is useful for creating simulations or random objects that can be reproduced.
seed – A number.

Example. Create simulated values that are reproducible.
> set.seed(5)
> rnorm(5)
[1] -0.84085548  1.38435934 -1.25549186  0.07014277  1.71144087
> set.seed(5)
> rnorm(5)
[1] -0.84085548  1.38435934 -1.25549186  0.07014277  1.71144087
The seed number you choose is the starting point used in the generation of a sequence of random numbers, which is why (provided you use the same pseudo-random number generator) you'll obtain the same results given the same seed number.
answered Apr 23, 2018 by zombie
• 3,690 points

Related Questions In Data Analytics

0 votes
1 answer

Which function can I use to clear the console in R and RStudio ?

Description                   Windows & Linux           Mac Clear console                      Ctrl+L ...READ MORE

answered Apr 17, 2018 in Data Analytics by anonymous
1,091 views
0 votes
1 answer

How can I use which() function in R ?

which() function determines the position of elements ...READ MORE

answered Sep 24, 2018 in Data Analytics by Daisy
• 8,040 points
28 views
0 votes
1 answer
0 votes
1 answer

Why should I adopt R programming

R Programming is the best mechanism for ...READ MORE

answered Oct 29, 2018 in Data Analytics by Maverick
• 10,040 points
19 views
0 votes
1 answer
0 votes
1 answer

What is set.seed() in R?

Let me explain in simple words, set seed ...READ MORE

answered Jul 9 in Data Analytics by anonymous
• 20,870 points
22 views
0 votes
2 answers

How to use group by for multiple columns in dplyr, using string vector input in R?

data = data.frame(   zzz11def = sample(LETTERS[1:3], 100, replace=TRUE),   zbc123qws1 ...READ MORE

answered Aug 5 in Data Analytics by anonymous
2,537 views
0 votes
1 answer

How to set global variables in R

To set global variables, you can use ...READ MORE

answered Apr 23, 2018 in Data Analytics by kappa3010
• 2,020 points
89 views
0 votes
1 answer

R function for finding the index of an element in a vector?

Yes, we can find the index of ...READ MORE

answered Apr 13, 2018 in Data Analytics by zombie
• 3,690 points
256 views
0 votes
1 answer

How can I select a CRAN mirror in R ?

There are many ways of doing so ...READ MORE

answered May 9, 2018 in Data Analytics by zombie
• 3,690 points
39 views