I would like to paste the value of the mean in a plot title using the title() function.
eg title("My plot \\n mean = mean(x)")
where x is a numeric vector of observations.
I know how to do this using plot(main = " ... ", ). Simply use paste() or substitute(expression()); however, this doesn't seem work with the title() function.
Any ideas?
Answer by @MarcoSandri is correct. The correct way of using the example codes you have written are,
title(main= paste("My plot \n mean =", mean(x)))
and
avg <- mean(x)
title(paste("My Plot \n Mean = ", avg))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.