What is set seed in R

633    Asked by AndrewJenkins in Salesforce , Asked on Jul 29, 2021

What is set.seed () in R? why is it used in regression and k-means clustering?

Answered by Anna Ball

Let me explain this issue in simple words,

set seed (value) where value specifies the initial value of the random number seed.

Syntax: set.seed(123)

In the above line,123 is set as the random number value.

The main point of using the seed is to be able to reproduce a particular sequence of 'random' numbers. and sed(n) reproduces random numbers results by seed. 

For more information about set.seed in r read the pdf of a few pages that explains all about set.seed in r in detail.

https://www.stata.com/manuals13/rsetseed.pdf

When the k-means clustering algorithm runs, set.seed() is used as a randomly generated seed to determine the starting centroids of the clusters. k-means-clustering-effect-of-random-seed



Your Answer

Interviews

Parent Categories