---
title: "Introduction to the `inTextSummaryTable` package"
author: "Laure Cougnaud"
date: "`r format(Sys.Date(), '%B %d, %Y')`"
output: 
  rmarkdown::html_document:
    toc: true
    toc_float: true
    toc_depth: 5
    number_sections: true
vignette: >
  %\VignetteIndexEntry{01 - Introduction to the inTextSummaryTable package}
  %\VignetteEngine{knitr::rmarkdown}
  \usepackage[utf8]{inputenc}
---

# Introduction

```{r options, echo = FALSE}
	
	library(knitr)
	opts_chunk$set(
		echo = TRUE, results = 'markup', warning = FALSE, 
		# stop document execution if error (not the default)
		error = FALSE, 
		message = FALSE, cache = FALSE,
		fig.width = 8, fig.height = 7,
		fig.path = "./figures_vignette/",
		fig.align = 'center')
	options(width = 170)
	# instead of warn = 0 by default
	# include warnings when they occur in the document
	options(warn = 1)
	
```

The package `inTextSummaryTable` contains functionalities to **create
complex table of summary statistics or counts of variables of interest**.

This table can be formatted to static

* **in-text table** for a **Clinical Study Report**,
* a **topline presentation**
* an **interactive table**, e.g. to be used inside the **medical
  monitoring report**.

These tables can be included into a `rmarkdown` document which can be
converted into `html`, `docx` and `pptx`.
Each table can be separately exported into a `text`, `docx` or `html `document.

We start the guidance to the functionalities of the `inTextSummaryTable`, via
loading the following packages.

```{r loadPackages}

	library(inTextSummaryTable)
	library(tools) # toTitleCase

```

## Data format

The input data for the creation of summary table should be a **data.frame**,
usually loaded from a _SAS_ data file (`sas7bdat` format).
The label of the variables stored in the `SAS` datasets is also used
for the title or the caption. 

Note that the `loadDataADaMSDTM` function of the `clinUtils` package 
can be used to import your study-specific dataset(s) of interest into R.

For this vignette, ADaM datasets included in the `clinUtils` package are used.

```{r loadData}	
	
	library(clinUtils)

	# load example data
    data(dataADaMCDISCP01)
	
	dataAll <- dataADaMCDISCP01
    labelVars <- attr(dataAll, "labelVars")
	
	# dataAll contains a list
	class(dataAll)
	# ... of ADaM datasets
	names(dataAll)
	# access a specific dataset
	head(dataAll$ADSL, 1)
	
	# check label of a subset of the variable(s)
	head(labelVars)
	# or for a specific variable:
	labelVars["USUBJID"]
	# or:
	getLabelVar(var = "USUBJID", labelVars = labelVars)

```

# Create your tables

Extensive documentation on how to create your in-text table is available in the vignette:
[Creation of in-text tables](inTextSummaryTable-02-createTables.html).

# Create standard set of tables

The creation of standard T(LF)ables is described in the vignette: 
[Creation of standard in-text tables](inTextSummaryTable-03-standardTables.html)

# Table formatting/export

If you are familiar with the creation of the tables, but you are wondering how
to:

* **export tables for specific formats as Word/PowerPoint/Html/R object**
* **save tables into separated documents**
* set specific **text formatting** (e.g. superscripts/subscripts)
* **filter and split** exported tables

then check the vignette: [Exporting of in-text tables](inTextSummaryTable-04-exportTables.html).

# Advanced use

If you are familiar with the creation and export of the tables, and you want to
know more on the functionalities less exposed to the users, you can check out
the vignette: [Advanced use of in-text tables](inTextSummaryTable-05-advanced.html).

# Aesthetics

The `inTextSummaryTable` package allow the user to set global options for the
color schemes of tables and visualization. The main advantage is that if
you wish to change the default palettes, it is possible to set your preferences
only once at the beginning of the R script or Rmd document, see the vignette: [Customization of aesthetics of in-text tables](inTextSummaryTable-06-aesthetics.html).

# Visualization

The summary statistics displayed in the table can also be visualized, see the
vignette: [Visualization of in-text table summaries](inTextSummaryTable-07-visualization.html).

# Appendix

## Session information

```{r includeSessionInfo, echo = FALSE, results = "asis"}
print(sessionInfo())
```
