Hao Zhu | f186023 | 2020-08-23 23:53:11 -0400 | [diff] [blame^] | 1 | mini_hist <- function(x, width = 60, height = 20, |
| 2 | dir = "kableExtra", file = NULL, |
| 3 | xaxt = 'n', yaxt = 'n', ann = FALSE, col = "gray", |
| 4 | ...) { |
| 5 | if (!dir.exists(dir)) { |
| 6 | dir.create(dir) |
| 7 | } |
| 8 | |
| 9 | if (is.null(file)) { |
| 10 | file <- tempfile("hist", dir, ".png") |
| 11 | } |
| 12 | |
| 13 | grDevices::png(filename = file, width = width, height = height, |
| 14 | bg = 'transparent') |
| 15 | graphics::par(mar = c(0, 0, 0, 0)) |
| 16 | graphics::hist(x, xaxt = xaxt, yaxt = yaxt, ann = ann, col = col, ...) |
| 17 | grDevices::dev.off() |
| 18 | return(file) |
| 19 | } |