<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/the-tidy-time-series-platform-tibbletime-0-1-0/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.business-science.io/code%20tools/2018/01/04/tibbletime-0-1-0.html"> business-science.io - Articles</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>We’re happy to announce the third release of the <code>tibbletime</code> package. This is a <strong>huge update</strong>, mainly due to a complete rewrite of the package. It contains a ton of <strong>new functionality</strong> and a number of breaking changes that existing users need to be aware of. All of the changes have been well documented in the <a rel="nofollow" href="https://business-science.github.io/tibbletime/news/index.html" target="_blank">NEWS</a> file, but it’s worthwhile to touch on a few of them here and discuss the <strong>future of the package</strong>. We’re super excited so let’s check out the vision for <code>tibbletime</code> and its new functionality!</p>
<h2>About Tibbletime</h2>
<p>For those new to to package, <code>tibbletime</code> is a new package that enables the creation of time aware tibbles. It’s sole purpose is to make working with time series in the tidyverse much easier! The <a rel="nofollow" href="https://business-science.github.io/tibbletime/" target="_blank">documentation</a> really explains everything, and here are a few important vignettes that can help get you up to speed on all of the functionality:</p>
<ul>
<li><a rel="nofollow" href="https://business-science.github.io/tibbletime/articles/TT-01-time-based-filtering.html" target="_blank">Time-Based Filtering</a></li>
<li><a rel="nofollow" href="https://business-science.github.io/tibbletime/articles/TT-02-changing-time-periods.html" target="_blank">Changing Periodicity</a></li>
<li><a rel="nofollow" href="https://business-science.github.io/tibbletime/articles/TT-03-rollify-for-rolling-analysis.html" target="_blank">Rolling Calculations In tibbletime</a></li>
<li><a rel="nofollow" href="https://business-science.github.io/tibbletime/articles/TT-03-rollify-for-rolling-analysis.html" target="_blank">Using tibbletime With dplyr</a> <strong>BRAND NEW!!</strong></li>
</ul>
<p><img alt="tibbletime overview" src="https://i2.wp.com/www.business-science.io/assets/tibbletime-0-1-0-overview.png?w=456" data-recalc-dims="1"></p>
<h2>Package roadmap</h2>
<p>The grand view is to have <code>tibbletime</code> function as a base package that others can build off of, utilizing the infrastructure that “knows” about the index column and provides support for time series transformations on tibbles. This can include extensions to finance, but also has room to grow into other areas such as economic forecasting, longitudinal studies, and other general time series analyses. We’ve already begun work on one such package, but that will be a post for another time ;).</p>
<p>At this point, the first bit of core functionality for <code>tibbletime</code> is complete. A few other functions will likely be added, but we will definitely support backwards compatability from here on out.</p>
<h2>New time series capabilities</h2>
<p>The <code>tibbletime</code> package was completely re-invisioned, making it much more flexible and general. Here are a few of the important new tools in <code>tibbletime</code>’s toolkit:</p>
<ul>
<li>
<p>A new index partitioning function (<code>collapse_index()</code>) that opens up powerful time based analysis with <em>any</em> <code>dplyr</code> function, rather than a specific (and limited) set of <code>time_summarise()</code>, <code>time_mutate()</code>, etc, functions.</p>
</li>
<li>
<p>Full support for <code>Date</code> and <code>POSIXct</code> classes as indices, and experimental support for <code>yearmon</code>, <code>yearqtr</code>, and <code>hms</code> which should get more stable over time.</p>
</li>
<li>
<p>A consistent API along with more informative argument names that attempt to give it that intuitive look and feel of a <code>tidyverse</code> package.</p>
</li>
</ul>
<p>The one downside is that we had to make a few <strong>breaking changes</strong>, but with this post you’ll be able to easily get your code up to speed with the new functionality. What follows are a few of the most important changes for those that already used <code>tibbletime</code> and are interested in seeing what has changed.</p>
<h2>Libraries</h2>
<p>Load the following libraries to follow along.</p>
<figure>
<pre><code data-lang="r"><span>library</span><span>(</span><span>tibbletime</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>library</span><span>(</span><span>dplyr</span><span>)</span></code></pre>
</figure>
<h3>time_collapse() -> collapse_index()</h3>
<p>Rather than having a function like <code>time_collapse()</code> that worked on an entire <code>tbl_time</code> object, it has been replaced with <code>partition_index()</code> and <code>collapse_index()</code> that solely manipulate the index (date) vector. This allows them to be used inside of a call to <code>mutate()</code> and gives the user more control over the outcome (for example, whether they want to assign it to a new column or overwrite the original index column).</p>
<figure>
<pre><code data-lang="r"><span>data</span><span>(</span><span>FB</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""><br data-jekyll-commonmark-ghpages=""></span><span>FB_time</span><span> </span><span>&lt;-</span><span> </span><span>FB</span><span> </span><span>%>%</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>as_tbl_time</span><span>(</span><span>date</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""><br data-jekyll-commonmark-ghpages=""></span><span>FB_time</span></code></pre>
</figure>
<figure>
<pre><code data-lang="text">## # A time tibble: 1,008 x 8<br data-jekyll-commonmark-ghpages="">## # Index: date<br data-jekyll-commonmark-ghpages="">##    symbol date        open  high   low close    volume adjusted<br data-jekyll-commonmark-ghpages="">##    </code></pre></figure>