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, 2022 in Data Science by avinash
• 1,840 points
403 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, 2022 by Sohail
• 3,040 points

Related Questions In Data Science

0 votes
0 answers

To speed up the tapply function in R, or another function to convert data frame into a matrix

I must turn a sizable dataset into ...READ MORE

Jun 24, 2022 in Data Science by Sohail
• 3,040 points
358 views
0 votes
0 answers

NA while using strptime function

Version 1.0.136 of R Studio for Windows ...READ MORE

Jul 9, 2022 in Data Science by avinash
• 1,840 points
367 views
0 votes
0 answers

Understanding of minbucket function in CART model using R

Let's say that the training data is ...READ MORE

Jul 20, 2022 in Data Science by avinash
• 1,840 points
574 views
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, 2022 in Data Science by gaurav
• 23,260 points
1,280 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,370 points
5,108 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, 2022 in Machine Learning by Dev
• 6,000 points
511 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,570 points
1,030 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
1,180 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, 2022 in Data Science by Sohail
• 3,040 points
463 views
0 votes
1 answer

Unexpected behavior for setdiff() function in R

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

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