Skip to content

Commit

Permalink
building vignette, build tests for qstack
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolalove committed Dec 11, 2020
1 parent 03ea5d8 commit b756888
Show file tree
Hide file tree
Showing 14 changed files with 599 additions and 72 deletions.
Binary file modified ._timeseries.Rproj
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.Rproj.user
.Rhistory
.RData
Meta
Binary file modified Meta/vignette.rds
Binary file not shown.
36 changes: 36 additions & 0 deletions doc/qstacktseries.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## ---- include = FALSE---------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(timeseries)
library(gapminder)
library(dplyr)

## ----dataset------------------------------------------------------------------
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)))

## ----example 1----------------------------------------------------------------
qstacktseries(testdf, year, rainfall, region, verbose = TRUE)

## ----example 2----------------------------------------------------------------
qstacktseries(gapminder %>%
filter(continent == "Asia"), year, gdpPercap, country, verbose = TRUE)

## ----example 3: Errors, error=TRUE--------------------------------------------

qstacktseries(gapminder %>%
filter(continent == "Asia"),continent, pop, country, verbose = TRUE)

qstacktseries(gapminder %>%
filter(continent == "Africa"), year, country, continent, verbose = TRUE)

57 changes: 57 additions & 0 deletions doc/qstacktseries.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: "qstacktseries"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{qstacktseries}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

```{r setup}
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:

```{r dataset}
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)))
```

```{r example 1}
qstacktseries(testdf, year, rainfall, region, verbose = TRUE)
```
Building a stacked area time series plot with a pre-existing data set: *gapminder*

```{r example 2}
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:

```{r example 3: Errors, error=TRUE}
qstacktseries(gapminder %>%
filter(continent == "Asia"),continent, pop, country, verbose = TRUE)
qstacktseries(gapminder %>%
filter(continent == "Africa"), year, country, continent, verbose = TRUE)
```

Loading

0 comments on commit b756888

Please sign in to comment.