The following is a minimal reproducible example (RE) - my attempt is to find out how I can use knitr to create complex dynamic documents, where here βcomplexβ refers not to the elements of the document and their layout, but to the non-linear logic of the basic fragments of R. Although provided by RE and its results show that a solution based on this approach may work well, I would like to know : 1) this is the correct approach to using knitr for such situations; 2) are there any optimizations that can be made to improve the approach; 3) what are the alternative approaches that can reduce the granularity of code fragments.
Download source package EDA (file "reEDA.R"):
EDA R Report Markdown Document (file "reEDA.Rmd"):
```{r KnitrSetup, echo=FALSE, include=FALSE} library(knitr) opts_knit$set(progress = TRUE, verbose = TRUE) opts_chunk$set( echo = FALSE, include = FALSE, tidy = FALSE, warning = FALSE, comment=NA ) ``` ```{r ReadChunksEDA, cache=FALSE} read_chunk('reEDA.R') ``` ```{r CleanEnv} ``` ```{r LoadPackages} ``` ```{r PrepareData} ``` Narrative: Data description ```{r PerformEDA} ``` Narrative: Intro to EDA results Let look at summary descriptive statistics for our dataset ```{r DescriptiveDataset, include=TRUE} print(d_diamonds) ``` Now, let examine each variable of interest individually. Varible Price is ... Decriptive statistics for 'Price': ```{r DescriptivePrice, include=TRUE} print(t_price) ``` Finally, let examine price distribution across the dataset visually: ```{r VisualPrice, include=TRUE, fig.align='center'} print(g_price) ```
The result can be found here:
http://rpubs.com/abrpubs/eda1
r reproducible-research knitr modularity r-markdown
Aleksandr Blekh
source share