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)
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:Simply wrap boxplot around that and you should get what you want. I'm sure there's a more efficient / better way to do that, but this should work for you.
Toy data:
(besides
Value
andCount
, I add a categorical variableGroup
)Use
purrr::pmap
andpurrr::reduce
to manipulate the data frame:A combination of
rep
anddata.frame
can be used as an approach if another variable is needed for classificationEg.
I solved a similar issue recently by using the 'apply' function on each column of counts with the 'rep' function:
...The above assumes that your values are in the first column and subsequent columns contain count data.