knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(timeseries) library(gapminder) library(dplyr)
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)
Building a stacked area time series plot with a pre-existing data set: gapminder
qstacktseries(gapminder %>% filter(continent == "Asia"), year, gdpPercap, country, verbose = TRUE)
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) qstacktseries(gapminder %>% filter(continent == "Africa"), year, country, continent, verbose = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.