Dear group members,
I am trying to label point estimates, lower and upper confidence limits in geom_pointrange but I got an error. The problem is with the 2 last geom_text in my code. I am trying to label some of the geom_pointrange not all.
My data:
> dput(pre_state_t12)
structure(list(Predicted = c(0.99994215562491, 0.454329193369023,
0.752714580480749, 0.999999712432362, 0.838845441403382), SE = c(0.00340145832186754,
0.159007108659988, 0.21801168405403, 0.00024122920915448, 0.19178485914968
), lower = c(1, 0.19150278825303, 0.234608027335444, 1, 0.243988915572354
), upper = c(1, 0.745335445352278, 0.967977117718246, 1, 0.98822880016548
),
site.name = structure(1:5, .Label = c("Egypt, n = 5", "Goosedam, n = 12",
"Greenbriar, n = 13", "Jarrett, n = 5", "Kentuck, n = 5"), class = "factor")), .Names = c("Predicted",
"SE", "lower", "upper", "
site.name"), row.names = c(NA, 5L), class = "data.frame")
My code and error
> p = ggplot(pre_state_t12, aes(
site.name, Predicted))
> p2012_state = p + geom_pointrange(aes(ymin = lower, ymax = upper), size = 1, stat = "identity") + theme_bw() + ylim(c(0,1)) + xlab("Region") + ylab("Occupancy rate") +
+ geom_text(aes(label = round(Predicted, 2)), hjust = c(-1.5, -1, -1, -1.5, -1), size = 4) +
+ geom_text(aes(label = c(0.19, 0.23, 0.24), x = c(2, 3, 5), y = c(0.19, 0.23, 0.24)), hjust = -1, size = 4) +
+ geom_text(aes(label = c(0.74, 0.97, 0.99), x = c(2, 3, 5), y = c(0.74, 0.97, 0.99)), hjust = -1, size = 4)
>
> p2012_state
Error: Aesthetics must be either length 1 or the same as the data (5): x, y, label
--
Manuel Spínola, Ph.D.
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspi...@una.cr
mspin...@gmail.com
Teléfono: (506) 8706 - 4662
Personal website:
Lobito de río
Institutional website:
ICOMVIS