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).

KnitR used in RStudio

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


Learning Modules

edit

Technical Tasks for Learners

edit
  • (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

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:

  • Install R-Studio and R on your computer.
  • Install the KnitR-Package in R-Studio.
  • Download Sample Data e.g. R Sample Data by Guru99[2]
  • Learn about KnitR with Screencasts (Youtube) and perform a basic KnitR tutorial so that you get the first dynamic report.
  • Advanced Learners/Spatial Analysis: Apply a scenario in the Risk Management Module for creating Risk Maps. What are additional requirements for the spatial analysis?
  • (Jupyter) Analyse the Open Source framework Jupyter and analyse the difference and similarities between KnitR and Jupyter. When will you use KnitR and when would you use Jupyter.
  • Analyse the COVID-19 outbreak and the requirements of dynamic updates in 2020. What are the requirements and constraints to create a dynamic report mechanism based on KnitR and R for the COVID-19 epidemics.
  • Explore the concept of Scientific Hackathon and explain why KnitR can be used as a development environment for decision support products!
  • (KnitR Templates) Create a KnitR template that loads input data from a dataset input.csv calls a process_data(...) function and creates an output.csv for processed data. Include some of source data and aggregated source data in the R-Markdown.

Some external knitR tutorials

edit

Wiki to Markdown Conversion with PanDoc

edit

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

References

edit
  1. WikiJournal of Medicine - An open access journal with no publication costs – About ISSN: 2002-4436 www.WikiJMed.org Frequency: Continuous Since: March 2014 Publisher: Wikimedia Foundation
  2. guru99-edu Github User (2019) R-Programming respository with R sample data in CSV format for learning R - URL: https://github.com/guru99-edu/R-Programming - retrieved 2024/05/06
  3. Quantum Geographic Information System (QGIS) - Open Source Software Package for Linux, Windows, Mac (2017) - LTR 2.18.11 access 2017/08/14 - https://www.qgis.org/en/site/forusers/download.html
edit