library(timeseries)
library(gapminder)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

This is how the function qstacktseries works:

Building a stacked area time series plot with a dummy data set:

  testdf <- data.frame(year = rep(seq(from = 1980, to= 1990, 1), 3),
                       rainfall = c(runif(11, 0, 100), rnorm(11, 70, 10),
                                    rnorm(11, 20, 20)),
                       temp = c(rnorm(11, 70, 30), rnorm(11, 45, 20), 
                                rnorm(11, 100, 10)),
                       daysofsun = c(NA, NA, rnorm(9, 280, 50), rnorm(11, 300, 30), NA, 
                                     rnorm(10, 340, 15)),
                       region = c(rep("A",11), rep("B", 11), rep("C", 11)))
qstacktseries(testdf, year, rainfall, region, verbose = TRUE)
#> Plotting time series...Done labelling plot!...Done applying default theme aesthetics!

Building a stacked area time series plot with a pre-existing data set: gapminder

qstacktseries(gapminder %>%
                filter(continent == "Asia"), year, gdpPercap, country, verbose = TRUE)
#> Plotting time series...Done labelling plot!...Done applying default theme aesthetics!

These are some errors you might see if qstacktseries is given non-numeric input for the time or voi inputs:


qstacktseries(gapminder %>%
                filter(continent == "Asia"),continent, pop, country, verbose = TRUE)
#> Error in qstacktseries(gapminder %>% filter(continent == "Asia"), continent, : Sorry, the time variable needs to be a numeric variable!

qstacktseries(gapminder %>%
                filter(continent == "Africa"), year, country, continent, verbose = TRUE)
#> Error in qstacktseries(gapminder %>% filter(continent == "Africa"), year, : Sorry, the variable of interest (dependent) needs to be a numeric variable!