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

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -