Skip to content

agg_png() gives a warning when specifying all of width, height, units, and res #16

@ilarischeinin

Description

@ilarischeinin

This seems really odd, but agg_png() fails for me (with error message the condition has length > 1) when I specify a value for all of width, height, units, and res, but not if I leave out one of them.

Below is a reprex. Whenever the message is "quartz_off_screen" and there is no visible plot, the function worked. But when it fails for the last case, the plot appears here as it didn't go into a file.

library(ragg)

agg_png("foobar.png"); plot(1:10); dev.off()
#> quartz_off_screen 
#>                 2
agg_png("foobar.png", units = "px", res = 72); plot(1:10); dev.off()
#> quartz_off_screen 
#>                 2
agg_png("foobar.png", width = 480, height = 480); plot(1:10); dev.off()
#> quartz_off_screen 
#>                 2
agg_png("foobar.png", width = 480, height = 480, units = "px"); plot(1:10); dev.off()
#> quartz_off_screen 
#>                 2
agg_png("foobar.png", width = 480, height = 480, res = 72); plot(1:10); dev.off()
#> quartz_off_screen 
#>                 2
agg_png("foobar.png", width = 480, units = "px", res = 72); plot(1:10); dev.off()
#> quartz_off_screen 
#>                 2
agg_png("foobar.png", height = 480, units = "px", res = 72); plot(1:10); dev.off()
#> quartz_off_screen 
#>                 2
agg_png("foobar.png", width = 480, height = 480, units = "px", res = 72); plot(1:10); dev.off()
#> Error in if (deparse(sys.call()) == "dev(filename = filename, width = dim[1], height = dim[2], ...)") {: the condition has length > 1

#> null device 
#>           1

Created on 2019-07-15 by the reprex package (v0.3.0)

Edit: condition has length > 1 is of course normally a warning and not an error. I thought reprex::reprex() runs as vanilla, but apparently it obeys my ~/.Renviron where I have this line:
_R_CHECK_LENGTH_1_CONDITION_ = true. I updated the title of the issue, as the function does work, but just gives out a warning when all the listed parameters are specified in the function call.

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