From Wikiversity
Jump to navigation Jump to search
KnitR used in RStudio

KnitR is package for the RStudio, which allows to produce word processing documents, PDF, presentations,... with real-time embedding of data. E.g. current stock exchange rates can fetched, analyse within R and dependent on the analysis phrases and results can be inject e.g. in the text. The package KnitR is often used within RStudio as a graphical user interface for calling commands and scripts for the underlying statistic software R (see Wikipedia:Knitr for details).

From the command line up to date reports can be generated automatically by processing a R-Markdown document and at processing time the current data sources (e.g. monitoring data) is evaluated in the statistical or numerical analysis.

If learners are able to see the R-Code in the learning document they can perform activities in the software for statistics on their own. Furthermore for research publications in the Wikiversity[1] readers can

  • reproduce the results,
  • learn from the methodology,
  • apply the R-code on their own data,
  • check if the algorithm are appropriate for experimental design
Knitr integration.png

Learning Modules[edit | edit source]

Technical Tasks for Learners[edit | edit source]

  • (Installation) Install RStudio and the package KnitR and create and process your first KnitR-document.
  • (Octave in KnitR) Analyse the possibility to integrate the calculations with Octave in a KnitR markdown document.

Learning Task[edit | edit source]

In the previous section the workflow of a integrated approach of KnitR was elaborated. Due to the fact that this concept is not implemented yet as extension in MediaWiki yet, the workflow cannot performed with code chunk for mathematical calculations in the MediaWiki of Wikiversity directly. But it possible to learn about the workflow in general:

Some external knitR tutorials[edit | edit source]

Wiki to Markdown Conversion with PanDoc[edit | edit source]

The OpenSource tool PanDoc is called the "swiss army knife" of document conversion. Assume we have a KnitR document of a scientific paper that contains the KnitR code chunks for processing the data, that was analysed.

  • converted the Markdown document of the paper with PanDoc-Online Converter in a MediaWiki document.
    • Create a sample document with the knitr-package in RStudio and save the R-Markdown file with the extension Rmd to your harddrive.
    • Copy the content of your R-Markdown document to PanDoc-Online Converter,
    • select Markdown (pandoc) as input format,
    • select MediaWiki as output format,
    • press Convert-button and analyze the generated MediaWiki syntax of the text.
  • The R-Code chunks for the analysis of the data (e.g. loaded from CSV file of spreadsheet document) is converted into a <code>-environment.
  • This converted KnitR document is stored together with the scientific papers in the WikiJournal (e.g. WikiJournal of Medicine). If sampling of data was performed in the same way the application of the KnitR-document with the new data will be performed in the same algorithmic way. This KnitR-approach contributes to a workflow for Reproducible Science.

See also[edit | edit source]

References[edit | edit source]

  1. WikiJournal of Medicine - An open access journal with no publication costs – About ISSN: 2002-4436 Frequency: Continuous Since: March 2014 Publisher: Wikimedia Foundation
  2. Quantum Geographic Information System (QGIS) - Open Source Software Package for Linux, Windows, Mac (2017) - LTR 2.18.11 access 2017/08/14 -

External links[edit | edit source]