tsibble v0.2.0
This release (hopefully) marks the stability of a tsibble data object (tbl_ts
). A tbl_ts
contains the following components:
key
: single or multiple columns uniquely identify observational units over time. A key consisting of nested and crossed variables reflects the structure underlying the data. The programme itself takes care of the updates in the "key" when manipulating the data. The "key" differs from the grouping variables with respect to variables manipulated by users.index
: a variable represent time. This together the "key" uniquely identifies each observation in the data table.index2
: why do we need the second index? It means re-indexing to a variable, not the second index. It is identical to theindex
most time, but start deviating when usingindex_by()
.index_by()
works similarly togroup_by()
, but groups the index only. The dplyr verbs, likefilter()
,mutate()
, operates on each time group of the data defined byindex_by()
. You may wonder why introducing a new function rather than usinggroup_by()
that users are most familiar with. It's because time is indispensable to a tsibble,index_by()
provides a trace to understanding how the index changes. For this purpose,group_by()
is just too general. For example,index_by()
+summarise()
aggregates data to less granular time period, leading to the update in index, which is nicely and intuitively handled now.interval
: aninterval
class to save a list of time intervals. It computes the greatest common factor from the time difference of theindex
column, which should give a sensible interval for almost all the cases, compared to minimal time distance. It also depends on the time representation. For example, if the data is monthly, the index is suggested to use ayearmonth()
format instead ofDate
, asDate
only gives the number of days not the number of months.regular
: since a tsibble factors in the implicit missing cases, whether the data is regular or not cannot be determined. This relies on the user's specification.ordered
: time-wise and rolling window functions assume data of temporal ordering. A tsibble will be sorted by its time index. If a key is explicitly declared, the key will be sorted first and followed by arranging time in ascending order. If it's not in time order, it broadcasts a warning.
Breaking changes
- Deprecated
tsummarise()
and its scoped variants. It can be replaced by the comboindex_by()
+summarise()
(#20).tsummarise()
provides an unintuitive interface where the first argument keeps the same size of the index, but the remaining arguments reduces rows to a single one. Analogously, it doesgroup_by()
and thensummarise()
. The proposedindex_by()
solves the issue of index update. - Renamed
inform_duplicates()
(defunct) tofind_duplicates()
to better reflect its functionality. key_vars()
andgroup_vars()
return a vector of characters instead of a list.distinct.tbl_ts()
now returns a tibble instead of an error.- No longer reexported
dplyr::do()
andtidyr::fill()
, as they respect the input structure. - Defunct
index_sum()
, and replaced byindex_valid()
to extend index type support.
New functions
index_by()
groups time index, as the counterpart ofgroup_by()
in temporal context.- A new S3 generic
count_gaps()
andgaps()
counts time gaps (implicit missing observations in time). yearweek()
creates and coerces to a year-week object. (#17)
API changes
fill_na.tbl_ts()
gained a new argument of.full = FALSE
..full = FALSE
(the default) insertsNA
for each key within its time period,TRUE
for the entire time span. This affects the results offill_na.tbl_ts()
as it only tookTRUE
into account previously. (#15)- Renamed the
drop
argument to.drop
in column-wise dplyr verbs. - Dropped the
duplicated
argument inpull_interval()
. group_by.tbl_ts()
behaves exactly the same asgroup_by.tbl_df
now. Grouping variables are temporary for data manipulation. Nested or crossed variables are not the type thatgroup_by()
thinks.
Improvements
- Added overall time span to the
glimpse.tbl_ts()
. - Slightly improved the speed of
fill_na()
.
Bug fixes
- Fixed
transmute.tbl_ts()
for a univariate time series due to unregistered tidyselect helpers. (#9). - Fixed bug in
select.tbl_ts()
andrename.tbl_ts()
for not preserving grouped variables (#12). - Fixed bug in
select.tbl_ts()
andrename.tbl_ts()
for renaming grouped variables.
Internal changes
- A
tbl_ts
gains a new attributeindex2
, which is a candidate of new index (symbol) used byindex_by()
. - The time interval is obtained through the greatest common factor of positive time differences. This covers broader cases than the minimal value.
attr(grouped_ts, "vars")
stores characters instead of names, same asattr(grouped_df, "vars")
.