Using ggplot2
in R, i'm trying to insert a red line that indicates the average of a chain. I would like to insert the average value close to the line so that it was not necessary to "deduct" the value.
I tried to use a negative coordinate for x, but it did not work, the value is behind the axis.
ggplot(data = chain.fmBC) +
geom_line(aes(1:25000, chain.fmBC$V2)) +
labs(y = "", x = "") +
labs(caption= "Bayes C") +
geom_hline(yintercept = mean(chain.fmBC$V2), colour = "RED") +
geom_text(label = round(mean(chain.fmBC$V2), 2),
x = 0, y = min(chain.fmBC$V2), colour = "RED")
this is a picture of my graph:
How could I put the value that is in red (media) to the left of the y-axis of the graph, between 0 and 5000, as if it were a label of the y-axis?