Determine axis breaks automatically for time variables

breaks_time(x, unit = "hours", n = 8)

Arguments

x

Numeric vector of times from which to determine breaks

unit

Character string for time units. Options include:

  • "hours" (default), "hrs", "hr", "h"

  • "days", "dys", "dy", "d"

  • "weeks", "wks", "wk", "w"

  • "months", "mons", "mos", "mo", "m"

n

Ideal number of axis breaks requested (default = 8). Passed to labeling::extended()

Value

A numeric vector of breaks

Examples

ntimes <- sort(unique(data_sad$NTIME))
breaks <- breaks_time(ntimes)