Knitr
   HOME

TheInfoList



OR:

knitr is an engine for dynamic report generation with R. It is a package in the programming language R that enables integration of R code into
LaTeX Latex is an emulsion (stable dispersion) of polymer microparticles in water. Latexes are found in nature, but synthetic latexes are common as well. In nature, latex is found as a milky fluid found in 10% of all flowering plants (angiosperms ...
,
LyX LyX (styled as ; pronounced ) (Based on 3 developers, they say it can be pronounced "Licks", "Lucks" and "Leeks") is an open source, graphical user interface document processor based on the LaTeX typesetting system. Unlike most word processors, ...
,
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
, Markdown,
AsciiDoc AsciiDoc is a human-readable document format, semantically equivalent to DocBook XML, but using plain-text mark-up conventions. AsciiDoc documents can be created using any text editor and read “as-is”, or rendered to HTML or any other for ...
, and reStructuredText documents. The purpose of knitr is to allow
reproducible research Reproducibility, also known as replicability and repeatability, is a major principle underpinning the scientific method. For the findings of a study to be reproducible means that results obtained by an experiment or an observational study or in a ...
in R through the means of
literate programming Literate programming is a programming paradigm introduced in 1984 by Donald Knuth in which a computer program is given as an explanation of its logic in a natural language, such as English, interspersed (embedded) with snippets of macros and t ...
. It is licensed under the
GNU General Public License The GNU General Public License (GNU GPL or simply GPL) is a series of widely used free software licenses that guarantee end users the Four Freedoms (Free software), four freedoms to run, study, share, and modify the software. The license was th ...
. knitr was inspired by Sweave and written with a different design for better
modularization Broadly speaking, modularity is the degree to which a system's components may be separated and recombined, often with the benefit of flexibility and variety in use. The concept of modularity is used primarily to reduce complexity by breaking a s ...
, so it is easier to maintain and extend. Sweave can be regarded as a subset of knitr in the sense that all features of Sweave are also available in knitr. Some of knitr's extensions include the R Markdown format (used in reports published on RPubs), caching, TikZ graphics and support to other languages such as
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
, Perl, C++,
Shell scripts A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manip ...
and CoffeeScript, and so on. knitr is officially supported in the
RStudio RStudio is an integrated development environment for R, a programming language for statistical computing and graphics. It is available in two formats: RStudio Desktop is a regular desktop application while RStudio Server runs on a remote server ...
IDE for R,
LyX LyX (styled as ; pronounced ) (Based on 3 developers, they say it can be pronounced "Licks", "Lucks" and "Leeks") is an open source, graphical user interface document processor based on the LaTeX typesetting system. Unlike most word processors, ...
, Emacs/ESS and the Architect IDE for data science.


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 * load data, * performs 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. For example: The Wilcoxon Sign test was applied as statistical comparison of the average of two dependent samples above. In this case, the calculated P-value was 0.56 and hence greater than the significance level (0.05 by default). This implies that "H0: there is no difference between the results in data1 and data2" cannot be rejected. The text fragments are selected according to the script's results. In this example, if the P-value was lower than the significance level, different text fragments would be inserted in the dynamic report. In particular, the second sentence would swap "less" for "greater," and the third sentence would be replaced to reflect rejection of the null hypothesis. Using this workflow allows creating new reports simply by supplying new input data, ensuring the methodology is reproduced identically.


See also

* The R Programming wikibook *
Reproducible research Reproducibility, also known as replicability and repeatability, is a major principle underpinning the scientific method. For the findings of a study to be reproducible means that results obtained by an experiment or an observational study or in a ...


References


External links

*
Repository
on GitHub
Example code
on GitHub
knitr package
on CRAN Free R (programming language) software Free statistical software Free TeX software Literate programming R (programming language) {{Free-software-stub