If we do it: a cd_summary() table over cd_trend(x, trend_start = c(1951, 1981)) says which row is which window. If we never do: two rows read Mean temperature / Annual with different slopes, told apart only by Years, which a reader has to subtract from the current year to decode.
Problem
cd_trend() accepts several trend_start values (R/cd_trend.R), and cd_summary() drops trend_start. The rows keep Years (n_years), which varies with the start, but nothing names the window. Same family as #98: #98 kept stations apart ( (variable) suffix) and raw vs anomaly trends apart (a conditional Trend on column).
Proposed Solution
Carry the start the way #98 carries the scale: a Start (or Window) column added only when the table holds more than one trend_start, so single-window tables keep their shape.
As built (PR #109): Start, not Window. It holds the start year that was asked of cd_trend(). A Window column would need an end year, which the trend table does not carry, and trend_start + n_years - 1 is wrong when a series has gaps. The column follows Period, or Trend on when that is present. It is decided over the whole table, and an NA start counts as a window of its own. Both vignettes had shown this bug, with 59 look-alike row pairs each. Their hidden trend-table chunk now also orders rows so each 1951/1981 pair sits on adjacent rows.
Found by the plan review for #98.
If we do it: a
cd_summary()table overcd_trend(x, trend_start = c(1951, 1981))says which row is which window. If we never do: two rows readMean temperature / Annualwith different slopes, told apart only byYears, which a reader has to subtract from the current year to decode.Problem
cd_trend()accepts severaltrend_startvalues (R/cd_trend.R), andcd_summary()dropstrend_start. The rows keepYears(n_years), which varies with the start, but nothing names the window. Same family as #98: #98 kept stations apart ((variable)suffix) and raw vs anomaly trends apart (a conditionalTrend oncolumn).Proposed Solution
Carry the start the way #98 carries the scale: a
Start(orWindow) column added only when the table holds more than onetrend_start, so single-window tables keep their shape.As built (PR #109):
Start, notWindow. It holds the start year that was asked ofcd_trend(). AWindowcolumn would need an end year, which the trend table does not carry, andtrend_start + n_years - 1is wrong when a series has gaps. The column followsPeriod, orTrend onwhen that is present. It is decided over the whole table, and anNAstart counts as a window of its own. Both vignettes had shown this bug, with 59 look-alike row pairs each. Their hiddentrend-tablechunk now also orders rows so each 1951/1981 pair sits on adjacent rows.Found by the plan review for #98.