Time Series Analysis in R the Tidyverse Way
A practical, beginner-friendly guide using tsibble, fable and friends
tstidyway is an educational book designed to introduce time series analysis using modern tidyverse framework in R. It offers a clear, step-by-step learning journey–from understanding time series data and exploring patterns, to forecasting using state-of-the-art models in the fable ecosystem.
The book emphasises tidy principles, helping learners and researchers move seamlessly from data wrangling to analysis and visualisations – all within the same grammar of data manipulation that makes the tidyverse so intuitive. This repository contains the source code for the book tstidyway which was created in RStudio with Quarto
It is expected that by the end of going through this book, readers will be able to:
- Understand time series structure and key concepts such as trend, seasonality, and autocorrelation.
- Prepare and visualise time series data using
tsibble,dplyrandggplot2. - Explore and decompose time series patterns with the
feastsandfabletoolspackage - Build and evaluate forecasting models using
fable - Apply best practices for tidy and reproducible time series workflows in R.
A practical dataset on Ghana's economic and environmental indicators (gh_data.csv) and monthly sales data (monthly_sales.csv) are used throughout the book. Some in-built datasets are also used for certain demonstrations.
These datasets provide real-world context and helps learners gain hands-on-experience with time series tasks such as trend detection, decomposition, and forecasting.
This resource is ideal for:
- R users with basic tidyverse knowledge who wants to dive into time series analysis.
- Students, researchers, and data analysts in fields like economics, environmental science and engineering
- Practitioners looking for a modern, clean and reproducible approach to forecasting in R
You can explore the book online here, but if you want it locally you on your computer you can clone this repository. Run the codes below in your RStudio console.
repo_url <- "https://github.com/gkagyen/tstidyway"
local_path <- file.path(tempdir(), 'learn-timeseries')
usethis::create_from_github(repo_url, destdir = local_path) 💡Tip: Make sure you have correctly setup git and github in your RStudio
tstidyway is an open and community-friendly project.
Contributions are highly welcome — whether you want to fix typos, improve explanations, or add examples!
Here’s how you can contribute:
-
Fork the repository on GitHub.
-
Create a new branch for your changes.
-
Edit the relevant
.qmdfile(s). -
Commit and push your changes.
-
Submit a pull request (PR) with a short description of your improvements.
-
Fix spelling or grammar mistakes.
-
Add examples or new exercises.
-
Suggest clarifications for sections that may be confusing.
-
Improve visualizations or code comments.
-
Add links to relevant external resources.
All contributors will be credited in the Acknowledgements section of this readme file
Special thanks to the Ghana R users community for their support. Another big thanksto the global R community, the quarto developers, the tidyverts developers, and the tidyverse developers for creating the amazing tools that power this work.
This book was developed as part of a learning and teaching initiative to make time series analysis more approachable for everyone — the tidyverse way.
This work is licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) license.
You are free to share, adapt, and build upon this material for any purpose, even commercially — as long as you give appropriate credit.
George Kyei Agyen
Data Analyst and Researcher
Ghana R User Community
📧 Contact: gkagyen@live.com
🌍 Github