---
title: "Introduction to lifelogr's visualization functions"
date: "`r Sys.Date()`"
output: 
  pdf_document:
    fig_width: 6
    fig_height: 3
vignette: >
  %\VignetteIndexEntry{Visualization Functions}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEngine{knitr::knitr}
  %\VignetteEncoding{UTF-8}
---

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

```{r}
library(lifelogr)
```

There are 3 functions which allow for a series of plots with just one function
call: `plot_sleep_all`, `plot_daily_all`, and `plot_intraday_all`.  Each acts 
like the `plot.lm` function, where users must click "enter" to see the next plot.

Each plot within the generic plot function can also be called individually.

### Sleep Plots
Here are the sleep plots for EX:
```{r}
plot_sleep_all(EX)
```

Users can also call each function individually using 
`plot_sleep(person, plot_type)`.
For example:
```{r}
plot_sleep(EX, "by_datetime")
```


Some plots have other options.

For example, `plot_sleep_start_end` has a `color_var = "day_of_week"` argument 
to color the lines by day of the week instead of weekend/weekday.
```{r}
plot_sleep_start_end(EX, "day_of_week")
```

### Daily Total Plots
Here are the plots for the daily totals for EX:
```{r}
plot_daily_all(EX)
```

Users can also call each function individually using:
```{r}
plot_daily(EX, "steps")
```

### Within Each day Plots
Here are the plots for intraday data (multiple data points collected within each
day).  The default is to aggregate the data by time intervals within each day
so that data for a "typical day" is displayed.
```{r}
plot_intraday_all(EX)
```

However, it is also possible to specify that the plots use the raw data and plot
over all date-times.

```{r}
plot_intraday_all(EX, FALSE)
```
