-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Vignette for using the PDF and Word output template
- Loading branch information
wfulp
committed
Aug 7, 2019
1 parent
c73d4bd
commit 1e21739
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
^LICENSE\.md$ | ||
^VISCtemplates\.Rproj$ | ||
^\.Rproj\.user$ | ||
^doc$ | ||
^Meta$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.Rhistory | ||
.RData | ||
.Rproj.user | ||
doc | ||
Meta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.html | ||
*.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: "Using the PDF and Word Output Template" | ||
output: rmarkdown::html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{Using the PDF and Word Output Template} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteEncoding{UTF-8} | ||
--- | ||
|
||
The VISC report Rmarkdown template knits to either a PDF or Word document. | ||
|
||
* To create a new report, create a new Rmarkdown from the "VISC Report (PDF & Word Output)" template. | ||
* Use the Knit button select either the PDF (visc_report) or Word (word_document2) output. | ||
* Note the shortcut Ctrl-Shift-K will run the first output in the YAML, will be the last output run (starts off as PDF first) | ||
* If you want to run both reports in one command, either use `rmarkdown::render()` with `output_format = 'all'`, or install the loom package and create a RStudio Addin (<https://github.com/thebioengineer/loom>). | ||
|
||
|
||
There are some new functions and coding conventions that help with knitting the report to both outputs. | ||
|
||
## Page breaks | ||
|
||
* For page breaks use the `visc_clearpage()` function. You can use this as a simple inline code: `` `r knitr::inline_expr("visc_clearpage()")` ``. | ||
+ `\clearpage` (from previous template) will not work on Word output. | ||
|
||
## Referencing | ||
` | ||
**Figure and table references** | ||
|
||
* For figure and table references use `visc_ref()` function. | ||
+ For example: `` `r knitr::inline_expr("visc_ref('fig:response-rate-plot')")` ``. | ||
* Make sure chunk names only use dashes or referring will not work (no spaces or underscores). | ||
* Do not use figure or table labels in chunk headings or kable code (e.g., don't use `fig.cap = "My Figure Caption \\label{my_figure_label}"`. Rmarkdown will automatically assign the chunk name as the figure/table reference label. | ||
|
||
**Sections** | ||
|
||
* For referencing sections, use `[Section header text]` in the text. | ||
+ `[Background]` gives: [Background]. | ||
+ `[Biological endpoints]` gives: [Biological endpoints]. | ||
|
||
**References/Bibliography** | ||
|
||
* For referencing papers, simply use the @ symbol before bib file reference (i.e. `@Huang:2013fl`). | ||
|
||
|
||
## Tables | ||
|
||
* Only output one table per code chunk. | ||
* Make sure to have `format = output_type` in the `kableExtra::kable()` call | ||
+ `output_type` is either "latex" or "pandoc" depending on current report output. | ||
* The table name will be chunk name plus "tab:". | ||
+ For example, if chunk name is "descriptive-stats" then the table label will be "tab:descriptive-stats" | ||
* Note that Word output cannot support many kableExtra features, such as `kableExtra::kable_styling()`. | ||
+ Set `warning=kable_warnings` chunk option, otherwise Word output will have unwanted warnings. | ||
|
||
## Figures | ||
|
||
* Only output one figure per code chunk. | ||
* Figure name will be chunk name plus "fig:". | ||
+ i.e. if chunk name is "-stats" then the table label will be "fig:descriptive-stats". | ||
|
||
## P values | ||
|
||
* When using `VISCfunctions::pretty_pvalues()` make sure to use `output_type = output_type`, `bold = pandoc_markup`, and , `italic = pandoc_markup`. This will give the appropriate markup depending on PDF or Word output. | ||
|