Skip to contents

The one-row-per-timeslice table the calendar is built on, as a plain data.frame — the exported accessor to prefer over reaching for x@leaftable (the twin of geoscales::geoscale_leaftable()). as.data.frame() and ggplot2::fortify() on a Calendar are equivalent, so ggplot(cal) + geom_*() pipelines work directly.

Usage

calendar_leaftable(x)

# S3 method for class 'Calendar'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

# S3 method for class '`timescales::Calendar`'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

# S3 method for class 'Calendar'
fortify(model, data, ...)

Arguments

x

A Calendar.

row.names, optional

Ignored (S3 signature compatibility).

...

Ignored.

model

A Calendar (the fortify() generic's argument name).

data

Ignored (S3 signature compatibility).

Value

A data.frame: one row per timeslice, with the timeframe columns plus share, width, weight and total. Each timeframe column holds the member of the row at that timeframe; the finest one holds the leaf timeslices.

Examples

head(calendar_leaftable(calendar("m12")))
#>   MONTH      share width weight      total
#> 1   m01 0.08493151     1      1 0.08493151
#> 2   m02 0.07671233     1      1 0.07671233
#> 3   m03 0.08493151     1      1 0.08493151
#> 4   m04 0.08219178     1      1 0.08219178
#> 5   m05 0.08493151     1      1 0.08493151
#> 6   m06 0.08219178     1      1 0.08219178
head(as.data.frame(calendar("m12")))
#>   MONTH      share width weight      total
#> 1   m01 0.08493151     1      1 0.08493151
#> 2   m02 0.07671233     1      1 0.07671233
#> 3   m03 0.08493151     1      1 0.08493151
#> 4   m04 0.08219178     1      1 0.08219178
#> 5   m05 0.08493151     1      1 0.08493151
#> 6   m06 0.08219178     1      1 0.08219178