I wonder to know whether is possible to plot automatically a figure like this one using R:
I must say that the previous image was done manually by using Inkscape. However, I'd like to know whether is possible to construct such kind of image automatically using R. It would save an enormous time.
I have the original data:
1 10.73 9.31 10.75 7.72 5.98 7.97
1 9.27 8.61 9.28 7.00 6.25 8.50
1 8.49 7.80 8.50 6.26 6.54 9.11
2 11.45 10.00 11.46 8.47 6.58 8.86
2 10.76 10.00 10.03 7.75 6.88 9.45
2 10.00 9.34 9.25 7.00 7.19 10.12
The first column is the category (in this case there are only two categories, 1 and 2). The upper row in each category is the upper 95%CL and the lower row in each category is the lower 95%CL. The other rows are the mean.
In this case, I have 6 different samples, which are shown in 6 columns after the category column.
You could do this in ggplot by first reshaping your data so each row is a confidence interval, getting the appropriate x-axis spacing for your grouped data:
Then you could plot, using
geom_rect
andgeom_segment
to get the shapes: