0
$\begingroup$

I would like to perform k mean clustering with k=3 and the Euclidean distance a 100 different time.

But it only gives me 2 iterations, how do i do a loop so it give me 100. Thanks

$\endgroup$

1 Answer 1

0
$\begingroup$
lapply(1:100, function(i) kmeans(ir, 3))

will give you a list of 100 repeats of that line of code.

$\endgroup$
1
  • $\begingroup$ Thank you. I have tried it but this just repeats the same loop 100 times. I need 100 different times. Any ideas? $\endgroup$
    – SuzieT
    Jul 12, 2022 at 20:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.