Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to avoid subdirectory overload - but it doesn't work yet #217

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions R/grattan_save.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#' @param dpi Plot resolution. Default is "retina".
#' @param ignore_long_title Default is FALSE. If TRUE, the check on a long title
#' won't be performed. This is useful if using ggtext syntax within titles.
#' @param subdirectory Logical. TRUE by default. If FALSE will not create a separate subdirectory for each chart.
#' @param ... arguments passed to `ggsave()`. For example, use
#' `device = cairo_pdf` to use the Cairo PDF rendering engine.
#' For `grattan_save_all()`, the `...` are passed to `grattan_save()`.
Expand Down Expand Up @@ -142,6 +143,7 @@ grattan_save <- function(filename,
latex = FALSE,
dpi = "retina",
ignore_long_title = FALSE,
subdirectory = NULL,
...) {

# param checks
Expand Down Expand Up @@ -171,6 +173,11 @@ grattan_save <- function(filename,

# create subdirectory
dir <- tools::file_path_sans_ext(filename)

if (isFALSE(subdirectory)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure there is a more elegant way than this - any hints?

dir <- dirname(dir)
}

filetype <- tools::file_ext(filename)
file_name <- tools::file_path_sans_ext(basename(filename))

Expand Down