Hi Marna,
If we assume a sample size of 1, something like this:
dat[sample(which(dat$group!="C"),ceiling(14*0.4),TRUE),]
dat[sample(which(dat$group=="C"),floor(14*0.6),TRUE),]
Then just step through the two subsets to access your samples.
One problem is that you will not get exactly 40 or 60 %,
Hello,
If 60% of the 14 samples come from group C, then 8.4 samples should come
from a group with 6 elements. Do you want sampling with replacement? If
so maybe the following will do.
perc <- c(0.4, 0.6)
tmp <- split(seq_len(nrow(dat)), dat$group == "C")
idx <- sapply(seq_along(tmp),
Hi R user,
I have samples with covariates for different classes, I wanted to choose
the samples of different groups with different probabilities. For example,
I have a 22 samples size with 3 classes,
groupA has 8 samples
groupB has 8 samples
groupC has 6 samples
I want to select a total 14
3 matches
Mail list logo