dir_git <- '~/github/provRmd'
library(tidyverse)
library(stringr)

dir_test <- file.path(dir_git, 'rmd_testing')

### set up provenance tracking for this script:
# document(); install()
library(provRmd)
prov_setup()### initializes prov_track and loads functions

read a table; capture prov info

table1_file <- file.path(dir_test, 'table1.csv')
table1      <- read.csv(table1_file, stringsAsFactors = FALSE)

table2_file <- file.path(dir_test, 'table2.csv')
write.csv(table1, table2_file)

table3_file <- file.path(dir_test, 'table3.csv')
write.csv(table1, table3_file)
source(file.path(dir_test, 'test_source.R'))

``` {r saving a plot} table1 <- read.csv(table3_file, stringsAsFactors = FALSE)

ggplot(table1, aes(x = cell_id, y = status, color = n_spp)) + geom_point()

ggsave(file.path(dir_test, 'plot.jpg'))

```r
DT::datatable(table1,   ### does not display system and session info
              caption  = 'this is a sample table:',              
              rownames = FALSE,
              class    = 'stripe hover compact',
              options  = list(dom = 'tp'))

The next section (below the divider) is the footer, knitted as a child

The code for the R footer looks like this:

prov_wrapup()

Note that it needs to be included in a code chunk with option results = 'asis' in order for all the text to display properly. The code generates Markdown, which is executed as if it were just part of this main document; it numbers the section ("Provenance") as a continuation of the numbering, and the variables are evaluated in the environment of the main document.

``` {r, message = FALSE, results = 'asis'}

prov_wrapup()

```



oharac/provRmd documentation built on June 25, 2019, 9:06 p.m.