[R] Using factor levels as coordinates with geom_rect
loris.bennett at fu-berlin.de
Tue Sep 23 09:05:36 CEST 2014
With ggplot2 I can use the following to create a rectangle
where the x values are levels of a factor. This works if I want the
rectangle to extend across a range of factor level. My question is this:
How can I create a similar rectangle around a single factor level?
My assumption is that I should be able to convert the factor to a
numerical value. I could then subtract and add a smaller number to
obtain xmin and xmax, respectively. However, I don't know how to
convert the factor level to a value which corresponds to its
x-coordinate on the plot.
I posted a longer version of this question on StackOverflow with the
full code, input data, and a plot of the output:
Unfortunately, I didn't get an answer.
This signature is currently under construction.
More information about the R-help