See https://github.com/yihui/knitr-examples/blob/master/037-graphics-hyperlink.Rnw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
<<insert-fun, echo=FALSE>>= | |
insert_fun = function(name) { | |
read_chunk(lines = capture.output(dump(name, '')), labels = paste(name, 'source', sep = '-')) | |
} | |
@ | |
\begin{document} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this script will generate a file 'R.xml' for auto-completion in Notepad++; I | |
# wrote it when my programming style was pretty bad, but this script seems to be | |
# still functional anyway | |
# R.xml will be generated under your current work directory: getwd() | |
# load some packages to the search path: | |
pkg <- installed.packages()[, 'Priority'] | |
sapply(names(pkg)[!is.na(pkg)], library, character.only = TRUE) | |
# you may load any installed packages here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pdf.options(width = 7, height = 5, family = "AvantGarde") | |
library(RColorBrewer) | |
library(animation) | |
# title page | |
# pdf('titlepic.pdf', width=7, height=4) | |
ani.options(nmax = 66, interval = 0) | |
data(HuSpeech) | |
par(mar = c(4, 4, 0.1, 0.1)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% see http://yihui.name/knitr/demo/listings/ for output | |
\documentclass{article} | |
% define a new environment to break lines for error messages | |
\lstnewenvironment{Serror}{\lstset{style=Routstyle,breaklines=true}}{} | |
<<setup, include=FALSE>>= | |
render_listings() | |
@ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\begin{document} | |
<<run-all, results='hide', message=FALSE>>= | |
library(xtable) | |
out = NULL | |
for (g in unique(mtcars$gear)) { | |
out = c(out, knit_child('template.Rnw', sprintf('gear-%s.tex', g))) | |
} |