I'm looking to create a couple types of sample
variables. I have two questions with sampling.
- Is there a way to sample and give a percentage of the split between choices? e.g.
sample(c("Hold", "Pass"), 10000, replace = TRUE)
will give an even chance to sample the 10000 observations betweenHold
andPass
, but what if I want a 25/75 split?
I could do sample(c(rep("Hold", 25), rep("Pass", 75)), 1000, replace = TRUE)
but is there a better way to do this?
- I would like to create a skewed
sample
, orrnorm
, say for example between the numbers 1000, and 100,000. But I want it to skew right, so that most of the values are around the 1000-10000 mark, and then a smaller and smaller as we approach 100,000.
I have found some documentation doing the following, and have played around with it to get a distribution that skews left:
rsn(n=45000, xi=1000, omega=20000, alpha=20, tau=0, dp=NULL)
I would like to understand more about how this works or if there is another way to do it.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire