Skip to content

ggsave() can't be used with devices taking file as argument instead of filename #3807

Closed
@bwiernik

Description

@bwiernik

In ggsave(), if device is specified and the device takes the file argument instead of filename, ggsave fails with an error: unused argument (filename = filename)

library(ggplot)
p <- qplot(cars[[1]], cars[[2]])
ggsave("plot.pdf", p, device = pdf)

For the grDevices devices that take file, ggsave customizes the call to use file instead, but this doesn't work for devices from other packages, such as devEMF::emf or Cairo::CairoSVG.

This appears to be caused by these changes to remove partial argument matching.
#2355
#2364

It would be nice if ggsave automatically caught this error, then retried with file instead of filename.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions