Time series trends

Before we look at product-level data, as a marketer for an e-commerce business, it will be beneficial to have a better understanding of the overall time series trends in the revenue and the numbers of orders or purchases. This will help us understand whether the business is growing or shrinking in terms of both its overall revenue and the numbers of orders it receives over time.

First, we are going to look into the number of orders over time. Take a look at the following code:

# install.packages("lubridate")library(lubridate)timeSeriesNumInvoices <- df %>%  group_by(InvoiceDate=floor_date(InvoiceDate, "month")) %>%  summarise(NumOrders=n_distinct(InvoiceNo))

In this code, we are using the group_by function first to group ...

Get Hands-On Data Science for Marketing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.