Learn R Programming

⚠️There's a newer version (1.48) of this package.Take me there.

knitr (version 0.6.3)

A general-purpose package for dynamic report generation in R

Description

This package provides a general-purpose tool for dynamic report generation in R, which can be used to deal with any type of (plain text) files, including Sweave, HTML, Markdown and reStructuredText. The patterns of code chunks and inline R expressions can be customized. R code is evaluated as if it were copied and pasted in an R terminal thanks to the evaluate package (e.g. we do not need to explicitly print() plots from ggplot2 or lattice). R code can be reformatted by the formatR package so that long lines are automatically wrapped, with indent and spaces being added, and comments being preserved. A simple caching mechanism is provided to cache results from computations for the first time and the computations will be skipped the next time. Almost all common graphics devices, including those in base R and add-on packages like Cairo, cairoDevice and tikzDevice, are built-in with this package and it is straightforward to switch between devices without writing any special functions. The width and height as well as alignment of plots in the output document can be specified in chunk options (the size of plots for graphics devices is still supported as usual). Multiple plots can be recorded in a single code chunk, and it is also allowed to rearrange plots to the end of a chunk or just keep the last plot. Warnings, messages and errors are written in the output document by default (can be turned off). Currently LaTeX, HTML, Markdown and reST are supported, and other output formats can be supported by hook functions. The large collection of hooks in this package makes it possible for the user to control almost everything in the R code input and output. Hooks can be used either to format the output or to run a specified R code fragment before or after a code chunk. The language in code chunks is not restricted to R only (there is simple support to Python and Awk, etc). Many features are borrowed or inspired by Sweave, cacheSweave, pgfSweave, brew and decumar.

Copy Link

Version

Install

install.packages('knitr')

Monthly Downloads

1,175,558

Version

0.6.3

License

GPL

Maintainer

Last Published

June 22nd, 2012

Functions in knitr (0.6.3)

knit2html

Convert markdown to HTML using knit() and markdownToHTML()
knit

Knit a document
fig_path

Path for figure files
knit_theme

Syntax highlighting themes
hook_plot_tex

Default plot hooks for different output formats
knit_env

The environment in which a code chunk is evaluated
knit_hooks

Hooks for R code chunks, inline R code and output
eclipse_theme

Download and convert a theme from eclipsecolorthemes.org to CSS
stitch

Automatically create a report based on an R script and a template
run_chunk

Run the code in a specified chunk
knitr-package

A general-purpose tool for dynamic report generation in R
knit_engines

Engines of other languages
build_dep

Build automatic dependencies among chunks
opts_knit

Options for the knitr package
write_bib

Generate BibTeX bibliography databases for R packages
opts_chunk

Default and current chunk options
all_patterns

All built-in patterns
pat_rnw

Set regular expressions to read input documents
knit_patterns

Patterns to match and extract R code in a document
knit2pdf

Convert Rnw to PDF using knit() and texi2pdf()
read_chunk

Read chunks from an external R script
hook_rgl

Built-in chunk hooks to extend knitr
render_latex

Set output hooks for different output formats
knit_child

Knit a child document
set_parent

Specify the parent document of child documents
spin

Spin goat's hair into wool
set_header

Set the header information
imgur_upload

Upload a image to imgur.com