How can I draw a random sample from a dataset, proportionate to size, based on different proportions for each value of a factor variable, in R
问题 I want to draw a random sample from my dataset, using different proportions for each value of a factor variable, as well as using weights stored in some other column. dplyr solution in pipes will be preferred as it can be inserted easily in long code. Let's take the example of iris dataset. Species column is divided into three values 50 rows each. Let's also assume the sample weights are stored in column Sepal.Length . If I have to sample equal proportions (or equal rows) per species, the