Skip to content

log_breaks gives error when there are no finite inputs #210

@paleolimbot

Description

@paleolimbot

When log_breaks() does not have any finite inputs, it is unable to compute breaks (this is the cause of tidyverse/ggplot2#2876). This seems to be unlike extended_breaks() or pretty_breaks(), both of which do not error when there are no finite values.

library(scales)

log_breaks()(c(0, Inf))
#> Error in seq.default(min, max, by = by): 'from' must be a finite number
extended_breaks()(c(0, Inf))
#> [1] 0 0 0 0 0

log_breaks()(c(0, NA))
#> [1] 0
log_breaks()(c(NA, NA))
#> Warning in min(x, na.rm = na.rm): no non-missing arguments to min;
#> returning Inf
#> Warning in max(x, na.rm = na.rm): no non-missing arguments to max;
#> returning -Inf
#> Warning in log_breaks()(c(NA, NA)): NaNs produced
#> Error in if (max == min) return(base^min): missing value where TRUE/FALSE needed
log_breaks()(c(-Inf, Inf))
#> Warning in log_breaks()(c(-Inf, Inf)): NaNs produced
#> Error in if (max == min) return(base^min): missing value where TRUE/FALSE needed
log_breaks()(numeric(0))
#> Warning in min(x): no non-missing arguments to min; returning Inf
#> Warning in max(x): no non-missing arguments to max; returning -Inf
#> Warning in log_breaks()(numeric(0)): NaNs produced
#> Error in if (max == min) return(base^min): missing value where TRUE/FALSE needed

extended_breaks()(c(0, NA))
#> [1] 0 0 0 0 0
extended_breaks()(c(NA, NA))
#> numeric(0)
extended_breaks()(c(-Inf, Inf))
#> numeric(0)
extended_breaks()(numeric(0))
#> numeric(0)

Created on 2019-05-26 by the reprex package (v0.2.1)

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