ts_calendar_heatmap_plot(
.data,
.date_col,
.value_col,.low = "red",
.high = "green",
.plt_title = "",
.interactive = TRUE
)
Introduction
Calendar heatmaps are a useful visualization tool for understanding patterns and trends in time series data. They are particularly useful for displaying daily data, as they allow for the visualization of multiple weeks or months at a time.
The ts_calendar_heatmap_plot()
function from the R library {healthyR.ts}
is a powerful tool for creating calendar heatmaps. This function takes in a time series object and creates a heatmap plot with daily data plotted on the calendar. The intensity of the color on each day corresponds to the value of the data for that day.
One application of calendar heatmaps is in understanding daily patterns in data such as website traffic or sales. For example, a business owner could use a calendar heatmap to identify trends in their daily sales data and make informed decisions about their operations. Similarly, a website owner could use a calendar heatmap to understand the daily traffic patterns on their site and optimize their content strategy accordingly.
Calendar heatmaps are also useful for identifying anomalies or unusual patterns in time series data. For example, a calendar heatmap could be used to identify unexpected spikes or dips in daily sales data, or to identify unusual patterns in website traffic.
In addition to their practical applications, calendar heatmaps are also aesthetically pleasing and can be a fun way to visualize data. The ts_calendar_heatmap_plot()
function allows for customization of the color palette and other visual options, making it easy to create visually appealing heatmaps.
Overall, calendar heatmaps are a useful tool for understanding patterns and trends in daily time series data. The ts_calendar_heatmap_plot()
function from the R library healthyR.ts is a powerful tool for creating calendar heatmaps and can be easily customized to suit the needs of the user.
Function
Let’s take a look at the function.
Now let’s see the arguments to the parameters.
.data
- The time-series data with a date column and value column..date_col
- The column that has the datetime values.value_col
- The column that has the values.low
- The color for the low value, must be quoted like “red”. The default is “red”.high
- The color for the high value, must be quoted like “green”. The default is “green”.plt_title
- The title of the plot.interactive
- Default is TRUE to get an interactive plot usingplotly::ggplotly()
. It can be set to FALSE to get a ggplot plot.
Example
Now for an example.
library(healthyR.ts)
<- data.frame(
data_tbl date_col = seq.Date(
from = as.Date("2020-01-01"),
to = as.Date("2022-06-01"),
length.out = 365*2 + 180
),value = rnorm(365*2+180, mean = 100)
)
ts_calendar_heatmap_plot(
.data = data_tbl
.date_col = date_col
, .value_col = value
, .interactive = TRUE
, )
Voila!