Reasons for using the set seed function

0 votes
Many times I have seen the set.seed function in R, before starting the program. I know it's basically used for the random number generation. Is there any specific need to set this?
Jun 1 in Data Science by avinash
• 940 points
15 views

1 answer to this question.

0 votes
The requirement is a desire for repeatable results, which may arise from attempting to debug your software or, of course, from attempting to redo what it does:

We will "never" reproduce these two findings because I specifically requested something "random":

R> an example (LETTERS, 5)
[1] "K" "N" "R" "Z" "G" "K" "N" "R" "Z" "G"
R> an example (LETTERS, 5)
[1] "L" "P" "J" "E" "D" "L" "P" "J" "E" "D" "L" "P" "
These two, on the other hand, are identical since the seed was planted by me:

R> sample.seed(42); set.seed(42); (LETTERS, 5)
[1] set.seed(42); sample "X" "Z" "G" "T" "O" R> set.seed(42); sample "X" "Z" "G" "T" "O" R> set.seed(42); (LETTERS, 5)
[1] R> "X" "Z" "G" "T" "O" R> "X" "Z" "G" "T" "O" R> "X" "Z
There's a lot of information out there; Wikipedia is a fantastic place to start. In essence, these RNGs are known as Pseudo Random Number Generators because they are totally algorithmic: given the input, they generate a random number.
answered Jun 20 by Sohail
• 2,960 points

Related Questions In Data Science

0 votes
0 answers
0 votes
1 answer

Converting xlsx to xls using Microsoft Office Compitablity Pack's excelcnv

Simply rearranging the positions of the parameters ...READ MORE

answered Mar 25 in Data Science by gaurav
• 13,460 points
74 views
0 votes
0 answers

Determine the data types of a data frame's columns

I'm using R and have loaded data ...READ MORE

Jun 1 in Data Science by avinash
• 940 points
12 views
0 votes
1 answer

Difference between the == and %in% operators in R

percent in percent "returns a vector of ...READ MORE

answered Jun 20 in Data Science by Sohail
• 2,960 points
16 views
0 votes
1 answer

How to sample n random rows per group in a dataframe?

You can assign a random ID to ...READ MORE

answered Jul 3, 2018 in Data Analytics by Sahiti
• 6,380 points
3,737 views
0 votes
1 answer

Choose specific number with probability

Examine the sample function. set.seed(1) sample(c(0,1), size=12, replace=TRUE, prob=c(0.2,0.8)) 1 ...READ MORE

answered Mar 14 in Machine Learning by Dev
• 6,000 points
26 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
423 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
468 views
0 votes
1 answer

How to implement Knn-algorithm without using k-nn function in r?

I created an example that demonstrates the ...READ MORE

answered Jun 24 in Data Science by Sohail
• 2,960 points
8 views
0 votes
1 answer

Unexpected behavior for setdiff() function in R

Asymmetric difference is provided by 18 setdiff. ...READ MORE

answered Jun 24 in Data Science by Sohail
• 2,960 points
11 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP