r - Taking samples from summarized data -
i have data in form output aggregate, except not have original non-aggregated data.
example:
data <- data.frame(grade=letters[1:4], count=c(3,9,4,1)) grade count 1 3 2 b 9 3 c 4 4 d 1 i sample population of grades, e.g. using sample. easiest way of taking sample (without replacement) summarized counts this?
do expect this?
> sample(with(data, rep(as.character(grade), count)), 10) [1] "b" "b" "d" "a" "c" "c" "b" "b" "c" "b"
Comments
Post a Comment