statistics - add mean value to histogram in R! -


i plot histogram mean (average) value on (mark example blue, bold line). try using plot command, if add parameter: "add=true" desn't work.

you can use abline() add lines plot:

x <- rnorm(100) mx <- mean(x) hist(x) abline(v = mx, col = "blue", lwd = 2) 

have @ ?par graphic parameters (like col , lwd).

edit:

regarding question in comments:
can plot lines using lines().
text() used text.
argument cex describes "character expansion factor".

also have @ quick-r overview of basic plotting r.

x <- rnorm(100, mean = 10) mx <- mean(x) hist(x) lines( c(mx,mx), c(0,15), col = "red", lwd = 2) lines(c(10, 11.5), c(0, 10), col = "steelblue", lwd = 3, lty = 22) text(mx, 18 , round(mx, 2)) text(mx, 12 , "big", cex = 5) 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -