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

Regression: ggsave() fails if device is function without ... #4539

Closed
bwiernik opened this issue Jul 2, 2021 · 3 comments · Fixed by #4674
Closed

Regression: ggsave() fails if device is function without ... #4539

bwiernik opened this issue Jul 2, 2021 · 3 comments · Fixed by #4674
Labels
bug an unexpected problem or unintended behavior

Comments

@bwiernik
Copy link
Contributor

bwiernik commented Jul 2, 2021

Since a9b3b17, if a device is passed to ggsave() and this device lacks a ... argument (at least if it also uses a file argument instead of filename), it produces an "unused argument" error.

ggplot2::ggsave("test.emf", ggplot2::ggplot(), device = devEMF::emf)
#> Saving 7 x 5 in image
#> Error in (function (file = "Rplot.emf", width = 7, height = 7, bg = "transparent", : unused argument (filename = "test.emf")

Created on 2021-07-02 by the reprex package (v2.0.0)

@clauswilke
Copy link
Member

Is this different from #4521?

@yutannihilation
Copy link
Member

It's a different package.

https://cran.r-project.org/package=devEMF

Looking at the diff of a9b3b17, I guess the problem is that we remap filename to file but don't remove the original one from the arguments, so probably both "file" and "filename" are passed?

ggplot2/R/save.r

Lines 161 to 172 in acaa98e

args <- formals(device)
call_args <- list()
if ("file" %in% names(args)) {
call_args$file <- filename
}
if ("res" %in% names(args)) {
call_args$res <- dpi
}
if ("units" %in% names(args)) {
call_args$units <- 'in'
}
dev <- function(...) do.call(device, modify_list(list(...), call_args))

@bwiernik
Copy link
Contributor Author

bwiernik commented Jul 3, 2021

Yes, that’s the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants