How to make a timeseries boxplot in R

前端 未结 3 919
忘掉有多难
忘掉有多难 2020-12-03 06:08

I\'m trying to make a time series boxplot using ggplot2.

I have montly values for many individuals.

I need to make a timeseries boxplot by month

3条回答
  •  醉酒成梦
    2020-12-03 06:42

    I create a function to create the plot you need.

    the function is:

    ts_plot_season <- function(x = x) {
    season <- cycle(x)
    season.factor <- factor(season)
    ggplot() + 
      geom_boxplot(mapping = aes(x = season.factor,
                                 y = x)) +
      labs(x = "Periodo", y =  "Serie")
    }
    

    Fox example:

     ts_plot_season(AirPassengers)
    

    I hope this help. I know this question is old, but i couldn't find some god answer on the web. So i think this will help to someone.

提交回复
热议问题