Knitr
   HOME

TheInfoList



OR:

knitr is a
software engine A software engine is a core software component, component of a Complex system, complex software system. The word "engine" is a metaphor of a car's engine. Thus a software engine is a complex subsystem. There is no formal guideline for what should ...
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. Latices are found in nature, but synthetic latices are common as well. In nature, latex is found as a wikt:milky, milky fluid, which is present in 10% of all floweri ...
,
LyX LyX (styled as LYX; pronounced ) is an open-source software, open source, graphical user interface document processor based on the LaTeX typesetting system. Unlike most word processors, which follow the WYSIWYG ("what you see is what you get") ...
,
HTML Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser. It defines the content and structure of web content. It is often assisted by technologies such as Cascading Style Sheets ( ...
,
Markdown Markdown is a lightweight markup language for creating formatted text using a plain-text editor. John Gruber created Markdown in 2004 as an easy-to-read markup language. Markdown is widely used for blogging and instant messaging, and also used ...
,
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 fo ...
, and
reStructuredText reStructuredText (RST, ReST, or reST) is a file format for textual data used primarily in the Python programming language community for technical documentation. It is part of the Docutils project of the Python Doc-SIG (Documentation Special Inte ...
documents. The purpose of knitr is to allow reproducible research in R through the means of
literate programming Literate programming (LP) is a programming paradigm introduced in 1984 by Donald Knuth in which a computer program is given as an explanation of how it works in a natural language, such as English, interspersed (embedded) with snippets of macr ...
. It is licensed under the
GNU General Public License The GNU General Public Licenses (GNU GPL or simply GPL) are a series of widely used free software licenses, or ''copyleft'' licenses, that guarantee end users the freedom to run, study, share, or modify the software. The GPL was the first ...
. knitr was inspired by Sweave and written with a different design for better modularization, 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 PGF/Ti''k''Z is a pair of languages for producing vector graphics (e.g., technical illustrations and drawings) from a geometric/algebraic description, with standard features including the drawing of points, lines, arrows, paths, circles, ellipse ...
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 (prog ...
,
Perl Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language". Perl was developed ...
, 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 command languages. Typical operations performed by shell scripts include file manipula ...
and
CoffeeScript CoffeeScript is a programming language that compiles to JavaScript. It adds syntactic sugar inspired by Ruby, Python, and Haskell in an effort to enhance JavaScript's brevity and readability. Some added features include list comprehension an ...
, and so on. knitr is officially supported in the
RStudio RStudio IDE (or RStudio) is an integrated development environment for R, a programming language for statistical computing and graphics. It's available in two formats: RStudio Desktop is a regular desktop application while RStudio Server runs ...
IDE for R,
LyX LyX (styled as LYX; pronounced ) is an open-source software, open source, graphical user interface document processor based on the LaTeX typesetting system. Unlike most word processors, which follow the WYSIWYG ("what you see is what you get") ...
, Emacs/ESS and the
Architect An architect is a person who plans, designs, and oversees the construction of buildings. To practice architecture means to provide services in connection with the design of buildings and the space within the site surrounding the buildings that h ...
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


References


External links

*
Repository
on
GitHub GitHub () is a Proprietary software, proprietary developer platform that allows developers to create, store, manage, and share their code. It uses Git to provide distributed version control and GitHub itself provides access control, bug trackin ...

Example code
on
GitHub GitHub () is a Proprietary software, proprietary developer platform that allows developers to create, store, manage, and share their code. It uses Git to provide distributed version control and GitHub itself provides access control, bug trackin ...

knitr package
on CRAN Free R (programming language) software Free statistical software Free TeX software Literate programming R (programming language) Software using the GNU General Public License {{Free-software-stub