0

How can different users obtain the same randomly generated matrix with rbinom assigning (0/1) in r?

Here's the applied code

data <- matrix(rbinom(30*6, 1, prior), 30, 6) I've tried set.seed() but it just generates similar results for me but different for other users

Buddy Bob
  • 5,829
  • 1
  • 13
  • 44
fatma
  • 1
  • 1
  • 1
    Are you just wanting to make the sampling reproducible? if so see `?set.seed` – user20650 Apr 20 '22 at 23:02
  • I need the generated result to be the same for me and different users – fatma Apr 21 '22 at 09:25
  • 1
    okay then using `set.seed(..)` before calling the rbinom will do this. (when there are stochastic elements to a script Its good practice to add a set.seed call to the start of the script). Note that you may see differences if you are comparing random numbers between different R versions due to some changes in R 3.6; see https://github.com/wch/r-source/blob/7f6cc784523dfa69087958633f7deb309d9c8718/doc/NEWS.Rd#L150-L161: – user20650 Apr 21 '22 at 09:35

0 Answers0