# KnitR/Workflow

Learn about the basic workflow in KnitR so you would be able to decide if additional learning modules make sense to you and the learning modules could help you to do standard repeating jobs with statistical software and document generation much easier in the future.

## Workflow of KnitR

KnitR consists of standard e.g. MarkDown document with R-code chunks integrated in the document. The code chunks can be regarded as R-scripts that

• preforms data processing and
• creates output data (e.g. descriptive analysis) or output graphics (e.g. boxplot diagram).

The implementation of logical conditions in R can provide text elements for the dynamic report depended on the statistical analysis.

## Dynamic Text Generation with Calculated Acceptance of $H_{0}$ Assumen that we have the following text is as text generation with acceptance of the H0 hypothesis with mentioning the calculated $p$ -value from a statistic software (in this case R)

```   The Wilcoxon Sign test was applied as statistical comparison of the average of two dependent samples data1 and data2.
In this case the the calculated P-value was 0.056 and hence greater than the significance (0.05 by default).
This implies that "H0: there is no difference between the
results in data1 and data2" must be accepted.
```

## Dynamic Text Generation with Calculated Rejection of $H_{0}$ Depending on the R results (here 0.056) the text fragments are determined by logical conditions in the R-script. If the P-value was 0.045, which is lower than the significance (0.05 by default). An other appropriate text fragment is inserted in the dynamic report.

```   The Wilcoxon Sign test was applied as statistical comparison of the average of two dependent samples data1 and data2.
In this case the the calculated P-value was 0.045 and hence smaller than the significance (0.05 by default).
This implies that "H0: there is no difference between the
results in data1 and data2" will be rejected.
```

By this workflow the replacement of the input data of the statistical or numerical analysis in R creates a reproducible report which the same methodology. The key in KnitR to accomplish this basic example of dynamic text generation is the application of text and numeric variables that are populate by R-Code, that are part of the source document.