vignettes/reports_vignette.md

title: "reports Package Vignette" author: "Tyler Rinker" date: '2014-05-28' output: html_document: css: assets/fix-bootstrap.css toc: yes pandoc_args: [ "--biblio", "references.bib", "--csl", "ecology.csl" ]

reports Package Vignette

Tyler Rinker

The reports package (Rinker, 2013) is designed to bring together the best R has to offer in report writing in an intuitive fashion. The user houses everything related to the writing process in one accessible location. The reports package assists in writing reports and presentations by providing a frame work that brings together existing R, LaTeX/.docx and Pandoc tools. The package is designed to be used with RStudio, MikTex/Tex Live/LibreOffice, knitr, slidify, knitcitations, Pandoc and pander. The user will want to download these free programs/packages to maximize the effectiveness of the reports package.

The reports package assumes the user has some familiarity with the report writing programs/packages it depends on. For a complete list of reports dependencies click here. This manual will not help the user to understand these dependencies as they have their own help documentation. Many functions in the reports package are set with defaults that assume the user is utilizing RStudio. This vignette assumes that the user is also operating out of the root directory of the new_report/presentation in RStudio.

Select from sections below:

    Symbol Conventions:
    ♦ = Example (R code)
    [YT] = Video Demo (click to watch)

Setting Up .Rprofile

The user may want to set the following options in her .Rprofile. This will add efficiency to your workflow. [YT]

Option Function 1 bib.loc The path to the users primary .bib file (I store this in DropBox) 2 name.reports The name that will be automatically added to a report/presentation 3 sources.reports Path(s) to additional scripts to be sourced on project startup 4 temp.reports The primary template to use to generate reports (see template) 5 github.user GitHub user name 6 speed.temp A speed dial like interface that allows the template argument to take a number 7 present.template Path to, or default, .Rmd file template for use in as the .Rmd used in the slidify presentations

The following is the code I added to my own .Rprofile:

1. options(bib.loc = "C:/Users/trinker/Desktop/PhD Program/MASTER.bib")
2. options(name.reports = "Tyler Rinker\\\\University at Buffalo\\\\Department of Learning and Instruction")
3. options(sources.reports = path.expand("~/path_1"), path.expand("~/path_2"))
4. options(temp.reports = "apa6.mod.qual_tex")
5. options(github.user = "trinker")
6. options(speed.temp = list(`1` = "wordpress_rmd", `2` = "basic_rmd", `3` = "apa6.mod.qual_tex"))
7. options(present.template = "revealjs")

Creating a New Report/Presentation

Creating a new report or presentation directory is easy. [YT]

The user can either preset the working directory or can supply a path to create the report/presentation directory in and then use the new_report or presentation functions.

setwd() method

setwd("C:/Users/trinker/Desktop")
new_report("MY REPORT")

path method

new_report("MY REPORT", path="C:/Users/trinker/Desktop")

You've just created your first report/presentation directory and you're ready to begin writing.

*Note The user can name the main directory differently from the names used within the directly by supplying a vector of length 2 to the report/presentation arguments as seen here:

new_report(c("Major1", "minor"))
presentation(c("Major2", "minor"))

What's In the new_report/presentation Directory

The directory created by the new_report or presentation functions houses multiple subdirectories and files that integrate to speed up work flow. Please see the following links for PDF descriptions of the contents of the reports/presentation directory.

Report Workflow Presentation Workflow click here

click here

Using reports Functions In-Text

reports has a number of HTML shortcut functions that utilize two capital letters as names. These functions are ideally used in text with `r XX(args)`. Thus `r HR2("http://www.talkstats.com/")` yields:

www.talkstats.com

This use does not require wrapping with cat or the print argument.

To better display the HTML code the following examples do not use in-text (in-line) coding. The examples use the following code chunk form (rarely used in an actual report):

```{r}
R_CODE(_HERE)
```

This means that wrapping with cat or the print argument are usually required, however, this is not typical in standard usage.

Directory Management

The reports package contains functions to help maintain directories. They can speed up workflow through automation of directory related tasks.

rdirs, folder, and delete

rdirs is a function designed to recursively create directories. This is particularly useful when used in combination with new_report/presentation for creating weekly lecture notes for a class or other similar repeated tasks. The following code chunks demonstrate uses for 3 directory management functions in the reports package:

  1. rdirs – recursive directory creation
  2. folder – create a directory
  3. delete – delete a directory(s)

*The next 5 code chunks are meant to be run sequentially

Chunk 1- Create directory with multiple subdirectories

fx <- folder(delete_me)
WD <- getwd()
setwd(fx)
rdirs(admin, 1:15, c("d", "f", "w"), c(1, 4, 6))

Chunk 2- Return just the character vector. rdirs takes care of the front end padding of numbers.

rdirs(admin, 1:15, c("d", "f", "w"), c(1, 4, 6), text.only = TRUE)
 [1] "admin_01_d_1" "admin_02_f_4" "admin_03_w_6" "admin_04_d_1"
 [5] "admin_05_f_4" "admin_06_w_6" "admin_07_d_1" "admin_08_f_4"
 [9] "admin_09_w_6" "admin_10_d_1" "admin_11_f_4" "admin_12_w_6"
[13] "admin_13_d_1" "admin_14_f_4" "admin_15_w_6"

Chunk 3- Create dated folders

rdirs(session, 1:12, seq(as.Date("2000/1/1"), by = "month", length.out = 12))

Chunk 4- Create director of subdirectories of working reports folders

setwd(WD)
gx <- folder(delete_me2)
setwd(gx)
x <- rdirs(admin, 1:15, c("d", "f", "w"), c(1, 4, 6), text.only = TRUE)
lapply(x, new_report)

View it...

Chunk 5- Clean up with delete and reset working directory

delete(c(fx, gx))
setwd(WD)

Image File Synchronization [YT]

The sync family of functions are also useful for syncing files between directories. This is particularly useful with the figure files in the REPORT and PRESENTATION directories and/or the img directory used by slidify (Vaidyanathan, 2012). The base version in the family, sync is generic and syncs files between 2 directories. The sync_all function is specifically designed to sync any files between the three image directories in a new_report/presentation directory.

To use sync_all simply type:

sync_all()

There are no arguments to sync_all, just run and the files between the following directories are synced:

  1. ~/REPORT/figure
  2. ~/PRESENTATION/figure
  3. ~/PRESENTATION/assets/img

Push Local Repo to GitHub

The user may choose to push a project (repository). The repo2github is designed for the initial push to github. Future pushes can be handled via RStudio or other git interface. The user may choose to initialize a push when new_report or presentation the project is created by adjusting the argument github = TRUE.

Using notes.xlsx

The notes.xlsx/notes.csv is a file located in the ARTICLES directory. It is useful to take notes from articles/websites/etc. and organize them here. The notes function can be used to view a truncated version of the notes. The citation functions also enables the user to insert in-text citations into a document with the quote taken from the article or other source. It is important that the format of notes.xlsx is respected in order for the citation family of functions to be utilized. In order for this workflow related to citations to be most effective the user must use a .bib file to manage citations. I use JabRef manage my bibliography. Here is a screen shot of notes.xlsx file.

notes.xlsx contains the following columns:

  1. Document (bib key) - The bib key from the .bib file (usually authorYEAR)
  2. Location (page) - The page number of the quote/passage (use an integer or integers separated by a dash)
  3. Gist/Quote - The quote or a gist of a passage
  4. Q - Is the row gist a quote? If so use b if not use n. Those marked y can be inserted as quotes into a document.
  5. Notes - An optional column to add notes to self

The Gist/QuoteQ should be written in markdown/html. The notes.xlsx file also contains a quick reference for html on the right side:

Format Text for notes.xlsx [YT]

To assist in copying and pasting text from documents (particularly PDFs) the QQ (quick quote) takes a text string (optionally from the clipboard) and formats the text for use with notes.xlsx. Non-ascii characters (e.g. ligatures) and \n are removed/converted (though the string should still be checked). By default the string is copied to the clipboard for easy pasting into notes.xlsx.

Citations

The reports package has an integrated system citation related functions that can be accessed in .tex, .Rnw and .Rmd documents.

The user can view the bibkey and document title of the references in the .bib files via the BV (bib view) function.

Example

head(BV())

  num bibkey           title                                   
1   1 Yihui20131       knitr: A general-purpose package for dyn
2   2 Yihui20132       Dynamic Documents with {R} and knitr    
3   3 Yihui20133       knitr: A Comprehensive Tool for Reproduc
4   4 Boettiger2013    knitcitations: Citations for knitr markd
5   5 Vaidyanathan2012 slidify: Generate reproducible html5 sli
6   6 Rinker2013a      {qdap}: {Q}uantitative Discourse Analysi

Citation Family of Functions The citation family of functions grab a quote and format the text taken from the notes.xlsx/notes.csv for LaTeX/.Rmd with optional citation included. Functions attempt to copy the output to the clipboard for easy paste inclusion.

Each of the functions in the cite family follow a pattern of (cite, parencite, textcite, posscite, poscite) prefix and (L or M) suffix (note that currently only parencite and textcite functions exist for markdown). The cite and textcite are in the form of LaTeX commands by the same name. posscite and poscite are user defined LaTeX function styles that are extensions of the textcite command to fit possessive and -s- ending possessives. They can be defined as:

\newcommand\posscite[1]{\citeauthor{#1}'s (\citeyear{#1})} 
\newcommand\poscite[1]{\citeauthor{#1}' (\citeyear{#1})}

The L and M correspond to LaTeX or markdown outputs; markdown relies on the knitcitations (Boettiger, 2014) package.

Example 1 - parenthesis cite

parenciteM(1, force.block = FALSE)
 "An **EXAMPLE**; feel "free" to *delete* it ***soon***" ´r  citep("Rinker2013a")´

"An EXAMPLE; feel "free" to delete it soon" (Rinker, 2013b, p. 12)

Example 2 - textcite

textciteM(1, force.block = FALSE)
´r  citet("Rinker2013a")´ "An **EXAMPLE**; feel "free" to *delete* it ***soon***"

Rinker (2013b)"An EXAMPLE; feel "free" to delete it soon"

The LaTeX (L) versions of the functions work in a similar fashion but are used in .Rnw documents.

Updating .bib File [YT]

The user may update the .bib files within the new_report/presentation created directories directly or may choose to update the master .bib file housed elsewhere (set with the bib.loc option in the .Rprofile). If the user opts for the second route the update_bib function will update all the .bib files in the respective directory(s) according to the master .bib file.

Document Conversion [YT]

The Pandoc based file conversion family of functions use preset path defaults (default is REPORT directory) to enable the user to quickly convert between document types. The user must have Pandoc installed and on the OS path. The function names are intuitive with the portion before the 2 being the current document type and the portion after is the desired outcome document type (from2to). Here is an example, converting the doc.tex file from the reports package library directory to a .docx file (when the user is employing these functions it is not necessary to provide arguments).

Example - file conversion

DOC <- system.file("extdata/doc_library/apa6.qual_tex/doc.tex", package = "reports")
BIB <- system.file("extdata/docs/example.bib", package = "reports")
tex2docx(DOC, file.path(getwd(), "test.docx"), path = NULL, bib.loc = BIB)

*Note that all of the conversion functions can be used to convert any legitimate Pandoc conversion but if the from2to format is not followed the documents and paths must be explicitly supplied as arguments to the reports conversion function.

HTML Shortcuts

The general format of the HTML examples is:

(a) the display of the code used

(b) the HTML code produced
(c) the way the HTML renders in a browser.

This table lists the HTML functions and the HTML tag types produced. Click on the left column function names to see a demonstration of its use.

Code HTML Tag CN courrier new EM email FT font HL highlight text HR hyperref HR2 hyperref (new window) BT button HS horizontal space VS verticle space IF iframe IM image IM2 image (short path) IW image wrap PN presenter notes RF reveal.js fragment SC sprecial character TB text box TB2 writable text box YT YouTube VM Vimeo col2hex hex colors

CN (courrier new)

Wraps text with a courier new font tag. A specified version of FT but more convenient for constant use of courier new tags.

CN("new_report()")
[1] <font face="courier">new_report()</font>

new_report()

EM (email)

Wrap an email to generate an HTML email tag.

EM("tyler.rinker@gmail.com", print = TRUE)
<a href="mailto:tyler.rinker@gmail.com" target="_blank">tyler.rinker@gmail.com</a>

tyler.rinker@gmail.com

FT (font)

Wraps text with a font tags. Conveniently detects c(face, size` and/or color) and creates a font tag with the supplied text.

Example 1

FT(6, text="guy")
[1] <font size="6">guy</font>

[1] guy

Example 2

FT(6, blue, text="guy")
[1] <font size="6" color="blue">guy</font>

[1] guy

Example 3

FT(6, red, times_new_roman, text="guy")
[1] <font size="6" color="red" face="times new roman">guy</font>

[1] guy

HL (highlight text)

Example 1

cat(HL("Do not trust robots!"), "They are bent on destruction.")
<font style="background-color: #FFFF00;">Do not trust robots!</font> They are bent on destruction.

Do not trust robots! They are bent on destruction.

Example 2

cat(HL("Jake is a cookie scientist,", color="pink"), "an honorable profession.")
<font style="background-color: #FFC0CB;">Jake is a cookie scientist,</font> an honorable profession.

Jake is a cookie scientist, an honorable profession.

HR/HR2/BT (hyperrefs and buttons)

Convert path/url to HTML href tag.

  1. HR - Wrap a path/url to generate an HTML href tag.
  2. HR2 - Convenience version of HR that opens in a new page.
  3. BT - Wrap a path/url to generate an HTML hyperlinked text button tag.

Example 1 - HR demo: no text given--basename used; opens in same window

HR(path="http://dl.dropbox.com/u/61803503/Likert.pdf", print = TRUE)  
<a href="http://dl.dropbox.com/u/61803503/Likert.pdf">Likert.pdf</a>

Likert.pdf

Example 2 - HR demo: no text given--basename used; opens in same window

HR("http://cran.r-project.org/", print = TRUE) 
<a href="http://cran.r-project.org/">cran.r-project.org</a>

cran.r-project.org

Example 3 - HR demo: text given; opens in same window

HR("http://www.rstudio.com/ide/download/desktop", "click me", print = TRUE)  
<a href="http://www.rstudio.com/ide/download/desktop">click me</a>

click me

Example 4 - HR2 demo: text given; opens in new window

HR2("https://github.com/trinker/reports", "reports", print = TRUE)  
<a href="https://github.com/trinker/reports" target="_blank">reports</a>

reports

Example 5 - BT demo

BT("http://trinker.github.io/reports/dependencies", "Click Here!", print = TRUE)
<form action="http://trinker.github.io/reports/dependencies">
    <input type="submit" value="Click Here!">
</form>

HS/VS (spaces)

Insert n iterations of HTML spacing into a document.

Example 1 - HS demo

cat(paste0("reports", HS(10), "end"))
reports&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

reports          end

Example 2 - VS demo: single space

cat(paste0("the", VS(), "end"))
the</br>end

theend

Example 3 - HS demo: multiple spaces

cat(paste0("the", VS(3), "end"))
the</br></br></br>end

theend

IF (iframe embedding)

Wrap a url to generate an HTML iframe tag.

Example 1

IF("https://dl.dropboxusercontent.com/u/61803503/MWE.html", print = TRUE, height=250)
<div style="text-align:center;">
     <iframe src="https://dl.dropboxusercontent.com/u/61803503/MWE.html" width="640" height="250">Your browser does not support iframes.</iframe>
</div>
Your browser does not support iframes.

Example 2

IF("http://www.online-stopwatch.com/countdown-clock/full-screen/", height=400, center = TRUE, print = TRUE)
<div style="text-align:center;">
     <iframe src="http://www.online-stopwatch.com/countdown-clock/full-screen/" width="640" height="400">Your browser does not support iframes.</iframe>
</div>
Your browser does not support iframes.

Example 3

IF("http://www.dosketch.com/", width=1100, height=650, print=TRUE)
<div style="text-align:center;">
     <iframe src="http://www.dosketch.com/" width="1100" height="650">Your browser does not support iframes.</iframe>
</div>
Your browser does not support iframes.

Example 4

IF("http://glimmer.rstudio.com/pssguy/TVShowRatings/", width="100%", height=650, print=TRUE)
<div style="text-align:center;">
     <iframe src="http://glimmer.rstudio.com/pssguy/TVShowRatings/" width="100%" height="650">Your browser does not support iframes.</iframe>
</div>
Your browser does not support iframes.

Example 5

IF("https://dl.dropboxusercontent.com/u/61803503/Slides/reports/index.html", width=1150, height=750, print=TRUE)
<div style="text-align:center;">
     <iframe src="https://dl.dropboxusercontent.com/u/61803503/Slides/reports/index.html" width="1150" height="750">Your browser does not support iframes.</iframe>
</div>
Your browser does not support iframes.

Example 6 Here's an example of embedding a beautiful interactive visualization compliments of the googleVis package (Gesmann & Castillo, 2011)

IF("https://dl.dropboxusercontent.com/u/61803503/presentations/tmp.html", width=770, height=680, print=TRUE)
<div style="text-align:center;">
     <iframe src="https://dl.dropboxusercontent.com/u/61803503/presentations/tmp.html" width="770" height="680">Your browser does not support iframes.</iframe>
</div>
Your browser does not support iframes.

IM/IM2/IW (images and text-wrapped images)

These functions generate an HTML image tag that embeds an image. IM2 not demonstrated as this function assumes local image source.

  1. IM - Wrap a path/url to generate an HTML tag. Often markup code: ![](url( lacks flexibility with centering and sizing. IM enables control of centering via altering the sty/center commands and control of sizing via the numeric values supplied to height and width.
  2. IM2 - A wrapper for IM that sets the base path to "assets/img/". This allows the users to just specify the image name that resides in one of the following directories: 1-"~/assets/img" or 2-"~/figure".
  3. IW - Text wrapped images.

Example 1 - IM demo: Use width=NULL to retain original size

IM("http://cran.r-project.org/Rlogo.jpg", width=NULL, print=TRUE)
<div style="width:480px;margin:auto;">
    <p><img src="http://cran.r-project.org/Rlogo.jpg"></p>
</div>

Example 2 - IM demo: uses default width = 540, height = IE(width, 360) to size

IM("https://dl.dropboxusercontent.com/u/61803503/packages/reports.PNG", print=TRUE)
<div style="width:567px;margin:auto;">
    <p><img src="https://dl.dropboxusercontent.com/u/61803503/packages/reports.PNG" width="540" height="360"></p>
</div>

Example 3 - IM demo: hyperlinked image

IM("http://cran.r-project.org/Rlogo.jpg", NULL, print=TRUE, link = "http://cran.r-project.org")
<div style="width:480px;margin:auto;">
    <p><a href="http://cran.r-project.org" target="_blank"><img src="http://cran.r-project.org/Rlogo.jpg"></a></p>
</div>

Example 4 - IM demo: assumed image directory

IM2("Rlogo.jpg", center=FALSE)
[1] "<img src=\"assets/img/Rlogo.jpg\" width=\"540\" height=\"360\">"
IM2("Rlogo.jpg", loc=2, center=FALSE)
[1] "<img src=\"figure/Rlogo.jpg\" width=\"540\" height=\"360\">"

Example 5 - IW demo: text wrapped image with hyperlink

`r IW("http://www.talkstats.com/images/misc/logo.png", "http://www.talkstats.com/", width=140, height=75)`

## <a href="http://www.talkstats.com/" target="_blank"><img src="http://www.talkstats.com/images/misc/logo.png" width="140" height="75"></a>
So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text! So much text!

PN (presenter notes)

Creates presenter notes (an aside of the class "notes") for slides (e.g., reveal.js slides). Multiline notes can be supplied with \n separating the lines or on separate lines as seen below.

Example 1 - single line

PN("some fancy notes", print = TRUE)
<aside class="notes">
some fancy notes <br>
</aside>
some fancy notes

Example 2 - multiline with \n as separator

PN("1) some\n2) fancy\n3) notes", print = TRUE)
<aside class="notes">
1) some <br>
2) fancy <br>
3) notes <br>
</aside>
1) some 2) fancy 3) notes

Example 3 - multiline on separate lines

PN("1) some2) fancy3) notes", print = TRUE)

<aside class="notes">
1) some  <br>
2) fancy  <br>
3) notes <br>
</aside>
1) some 2) fancy 3) notes

RF (reveal.js fragments)

Slidify uses to include animated fragments (see this example) in reveal.js slides. This is required per each slide. Using `r RF()` reduces the typing involved with this action.

RF()
[1] "<script>\n$('ul.incremental li').addClass('fragment')\n</script>\n"

SC (special character)

The general use of SCis to provide a character string of length 2. The first character is a letter and the second is one of the following symbols (left column) and HTML equivalent (right column):

Key Symb HTML apostrophe ' acute back tick ` grave colon : uml tilde ~ tilde carat ^ circ slash / slash lowercase o o ring comma , cedil

The user can create non-HTML characters with SC that will not be converted (i.e., SC("b~") would yield "&btilde;" and would not be converted appropriately).

SC("A'")

[1] "Á"

SC('a\'')  #can use single quotes with escape 

[1] "á"

SC("a`")

[1] "à"

SC("n~")

[1] "ñ"

SC("o:")

[1] "ö"

SC("(c)")

[1] "©"

SC("(r)")

[1] "®"

SC("c|")

[1] "¢"

SC("o/")

[1] "ø"

SC("ao")

[1] "å"

SC("c,")

[1] "ç"

SC("p") 

[1] "¶"

SC("P") 

[1] "¶"

SC("E")

[1] "€"

SC("Y")

[1] "¥"

SC("/")

[1] "÷"

SC("+-")

[1] "±"

SC("L")

[1] "£"

SC("tm") 

[1] "™"

SC("S") 

[1] "§"

SC("<") 

[1] "<"

SC(">") 

[1] ">"

SC("~")

[1] "~"

SC("o")

[1] "°"

TB (text box)

Wrap text to generate an HTML text box tag. TB is a traditional text box using div tags whereas TB2 is a writable text box.

Example 1

TB("I like ice cream!", print=TRUE)
<div style="background-color: white; border-radius: 5px; padding:10px; border: 1px solid black; color: black; ">
    I like ice cream!
</div>
I like ice cream!

Example 2

TB("Free cookies for a year!", col = "red", font.col="white", print=TRUE)
<div style="background-color: red; border-radius: 5px; padding:10px; border: 1px solid black; color: white; ">
    Free cookies for a year!
</div>
Free cookies for a year!

Example 3

TB2("I like ice cream!", print=TRUE)
<div align="left">
    <input style="text-align:center" name="box1" type="text" value="I like ice cream!" size="17" />
</div>

Example 4

TB2("Free cookies for a year!", print=TRUE)
<div align="left">
    <input style="text-align:center" name="box1" type="text" value="Free cookies for a year!" size="24" />
</div>

YT/VM (insert video)

Returns a character vector of an HTML iframe tag that embeds a YouTube or Vimeo video.

Example 1- YouTube using url tag

YT("ArHQjQyIS70", print = TRUE)
<iframe class="youtube-player" type="text/html" width="640" height="360" src="http://www.youtube.com/embed/ArHQjQyIS70?autoplay=0" frameborder="0"></iframe>

Example 2- YouTube using full url

YT("http://www.youtube.com/watch?v=ArHQjQyIS70", print = TRUE)
<iframe class="youtube-player" type="text/html" width="640" height="360" src="http://www.youtube.com/embed/ArHQjQyIS70?autoplay=0" frameborder="0"></iframe>

Example 3- Vimeo video

VM("http://vimeo.com/54007714", print = TRUE)
<iframe src="http://player.vimeo.com/video/54007714" width="640" height="360" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>

col2hex (colors)

Convert R colors() to Hexadecimal.

col2hex("darkblue")
[1] "#00008B"
col2hex(c("darkblue", "red"))
[1] "#00008B" "#FF0000"
cat(paste0("<hr color=\"", col2hex("red"), "\" size=\"4\">"))
<hr color="#FF0000" size="4">

Custom Templates [YT]

The user can create a document template framework for template personal use or submission with the doc_temp function. This function generates a document template for personal use or submission to the reports package to be included as a template in the doc_library. This function is similar to package.skeleton.

Odds and Ends

Reveal.js Slide Notes Locally (No Internet Connection)

Often you may find yourself in situations in which you have no Internet access. The slide notes in Reveal.js depend upon the presentation being hosted on a server, otherwise the notes will be inaccessible. However, setting up a local host enables viewing slide notes without an Internet connection. This can be accomplished via Python.

Before a Reveal.js presentation can be shown the user must:

Install Python and make it accessible from the command line [YT]

The user may then click on the bash/batch file generated by local_host and run the presentation locally. [YT] (note that this file must be clicked on outside of RStudio or the user may use FUN("run_lh", "local_host") to create and run the local host). The bash/batch file that is generated automatically creates a local host and opens the directory of the presentation for automatic access to locally hosted presentations.

Conversely, the user may want to operate from the command line. If this approach is used the following must be conducted each time you want show a presentation locally. [YT]

  1. Open the command line and change the directory to the Reveal.js HTML presentation
  2. Run python -m SimpleHTTPServer in the command line
  3. Use http://localhost:8000/THE_NAME OF_REVEALJS_PRESENTATION.html in the browser url bar

Special Thanks to Dason Kurkiewicz and Ramnath Vaidyanathan for working the local host out.

Custom style.css With RStudio + knitr [YT]

When using knitr with RStudio's Knit HTML button a standard style.css file is utilized and thus control over aesthetics of the document is limited. The custom_css provides the frame work (generates ~css/style.css and style.R files in the correct places) that allows a custom style.css file to be used with RStudio + knitr. The user simply runs:

custom_css()

After the appropriate files are created the user adds custom styling to the ~/css/style.css. The user has to source before the custom styles will be applied. The user may specify rfprofile = TRUE in custom_css to add the style.R to the .Rprofile for sourcing upon startup. Otherwise, the user must open the style.R as the active tab in RStudio, check the Source on Save box and the click the save icon.

Note that the path to a style.css can be supplied to custom_css via the style.css argument. This may be a user defined file or an internal file from the reports style.css library (see css_styles). For examples see: https://github.com/trinker/style.css_examples. Feel free to submit your own style.css to the reports package <reports.rpackage@gmail.com> marked with style.css template in the subject line.

Presentations (RStudio's .Rpres and Slidify (Vaidyanathan, 2012))

The reports package relies on the flexible slidify package and lightweight RStudio's .Rpres framework for presentation generation. For possible slidify templates that can be supplied to present in project generating functions use the slidify_templates function (for the RStudio .Rpres option use present = "rstudio"). For slidify examples see: https://github.com/ramnathv/slidifyExamples. The user will want to become familiar with both of these presentation approaches.

Acknowledgements

The reports package is just a collection of the best R tools. A special thanks to Yihui Xie (2013) for his work with the knitr package and Ramnath Vaidyanathan for his slidify package. These R packages are the core of the reports package. For a complete list of reports dependencies click here.

References



trinker/reports documentation built on May 31, 2019, 9:51 p.m.