Skip to content

Commit

Permalink
improve write_fig
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed May 17, 2023
1 parent e4a405f commit 75cef6e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @export
print.data.table <- function(d, n = NULL, ..., maxrows = 1e6) {
if (is.null(n)) n = getOption("datatable.print.nrow") %||% 10

# options(datatable.print.nrow = 100)
# cat(sprintf("[data.table]: %s \n", dim_desc(d)))
if (nrow(d) <= maxrows) {
cat("[data.table]: \n")
Expand Down
4 changes: 3 additions & 1 deletion R/write_fig.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ write_fig <- function (p, file = "Rplot.pdf", width = 10, height = 5,
}
}
outdir = dirname(file)
mkdir(outdir)

filename = file_name(file)
file_exts = if (is.null(devices)) file_ext(file) else devices
if (length(file_exts) == 1 && (is.na(file_exts) || file_exts == "")) file_exts = "pdf"
Expand All @@ -48,7 +50,7 @@ write_fig <- function (p, file = "Rplot.pdf", width = 10, height = 5,
process <- function() {
for(i in seq_along(file_exts)) {
file_ext = file_exts[i]
outfile = sprintf("%s/%s.%s", outdir, filename, file_ext)
outfile = sprintf("%s/%s.%s", outdir, filename, file_ext) %>% path_mnt()

dev_open(outfile, width, height, res, use.cairo_pdf)
# 1. print plot
Expand Down

0 comments on commit 75cef6e

Please sign in to comment.