Boxplot of pre-aggregated/grouped data in R
问题 In R I want to create a boxplot over count data instead of raw data. So my table schema looks like Value | Count 1 | 2 2 | 1 ... Instead of Value 1 1 2 ... Where in the second case I could simply do boxplot(x) 回答1: I'm sure there's a way to do what you want with the already summarized data, but if not, you can abuse the fact that rep takes vectors: > dat <- data.frame(Value = 1:5, Count = sample.int(5)) > dat Value Count 1 1 1 2 2 3 3 3 4 4 4 2 5 5 5 > rep(dat$Value, dat$Count) [1] 1 2 2 2 3