Here is one way. For some dummy data
set.seed(2) dat <- rnorm(100, mean = 3, sd = 3)
calculate resume
sdat <- summary(dat)
Then we can paste the names of the summary statistics and their values ββwith paste() , and collapse one line
summStr <- paste(names(sdat), format(sdat, digits = 2), collapse = "; ")
Note that I am formatting statistics values ββto have only two significant digits using format() . This can be added to the plot as subtitles using the title() function
op <- par(mar = c(7,4,4,2) + 0.1) hist(dat) title(sub = summStr, line = 5.5) par(op)
I am pushing subtitles on the chart a bit through the line argument.

Gavin simpson
source share