Using R, generate data from the Bernoulli(p), for various sample sizes (n= 10, 15, 20, 25, 30, 50, 100, 150, 200), for p = 0.01, 0.4, 0.8
I know how to do it for one case using the rbinom function. Like for the first scenario: rbinom(n=10, size=1, p=0.01).
My aim is to build a function that could compute all these scenarios preventing me to do all of them individually.
The following function will give you a list of list. I tried to give them appopriate naming.
Just call it like
ff(n=c(10,15,20),probs = c(0.01,0.4,0.8))and you will get a list of length 3 (for every n) which contains a list of length 3 (for every probability) with the vectors from the bernoulli-sample.