箱线图按月
Boxplot by month
我有一个月度时间序列,其中包含这种格式的销售额(因此没有月份或年份列):
ts(data = Datos, start = c(2015,1), end = c(2020,12), frequency = 12)
如何按月绘制多箱线图?
如果您想使用箱线图显示给定五年内特定月份的变化,您可以尝试:
library(tidyverse)
library(tsibble)
ts(data = sample(100), start = c(2015,1), end = c(2020,12), frequency = 12) %>%
as_tsibble() %>%
mutate(month = as.factor(month(index))) %>%
ggplot(aes(month, value)) +
geom_boxplot()
我有一个月度时间序列,其中包含这种格式的销售额(因此没有月份或年份列):
ts(data = Datos, start = c(2015,1), end = c(2020,12), frequency = 12)
如何按月绘制多箱线图?
如果您想使用箱线图显示给定五年内特定月份的变化,您可以尝试:
library(tidyverse)
library(tsibble)
ts(data = sample(100), start = c(2015,1), end = c(2020,12), frequency = 12) %>%
as_tsibble() %>%
mutate(month = as.factor(month(index))) %>%
ggplot(aes(month, value)) +
geom_boxplot()