Sampling in R is pretty straightforward, but I am stumbling on the following. I want to generate a random sample of one thousand 0's and 1's where each sample unit of 1 has its own probability of selection. The code I am using is as follows:
Sample <- sample (0:1, 1000, replace = T, prob = c(data$No, data$Yes))
Where data$No
is the probability vector of the individual not doing action N with data$Yes
being the probability vector that the individual will do it. Where No + Yes = 1
Each of the 1000 individuals has their own unique probability of doing the action.
I want to generate probable outcomes of doing the action based on each individuals unique probability. But R is fighting me every step of the way.
Aucun commentaire:
Enregistrer un commentaire