Boxplot using pre-calcluated quartiles and average



Hello -

(also posted to ggplot2 google group)

Using a dataset such as:
(* - where other fields can be things like major, geographic location, etc..for this example let's use major)

gpa_avg gpa_25th gpa_75th gpa_std year other_field (*)
3.50 3.20 3.90 .15 2017 econ
3.48 3.17 3.87 .14 2017 history
3.51 3.19 3.91 .15 2016 econ
3.47 3.17 3.88 .14 2016 history

I'd like to be able to use ggplot make a boxplot (without whiskers) faceting by year and the other field(s). The data will be like this rather than the full panel data because of the size of the data given the numbers of years (usually more than 2).

I've made boxplots in ggplot using full-panel data but can't find via google, stack overflow or this groups archives the solution to this specific question.




Pre-emptive apology for the cross-posting. Just now seeing I shouldn't have.



As a custom figure with ggplot my thinking would be to draw on geom_rect or geom_tile, either as a big rectangle with a geom_line divider or as two rectangles (in which case apply gather from tidyr to the data before plotting to make an entry for each rectangle.

However, at the moment all your values are for the vertical coordinates, so you may want to introduce some horizontal coordinates for graphing. If, in the above example, you wanted to put all the subjects in the same panel when faceting by year, you could group_by year and mutate xlow as row_number() - 0.3 and xhigh as row_number + 0.3