Skip to content

Instantly share code, notes, and snippets.

@Thell
Created June 6, 2015 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thell/843053aee9fcc53a7b83 to your computer and use it in GitHub Desktop.
Save Thell/843053aee9fcc53a7b83 to your computer and use it in GitHub Desktop.
---
title: "testfn"
output: html_document
---
```{r knitr-setup, include=FALSE, echo=FALSE}
library(knitr)
```
```{r insert-fun, echo=FALSE}
insert_fun = function(name) {
read_chunk(lines = capture.output(dump(name, '')), labels = paste(name, 'source', sep = '-'))
}
```
```{r insert-lm, echo=FALSE}
insert_fun('lm')
```
```{r lm-source, eval=FALSE, tidy.opts=list(width.cutoff=30)}
```
```{r lm-source, eval=FALSE, tidy=TRUE, tidy.opts=list(width.cutoff=30)}
```
\documentclass{article}
\begin{document}
<<insert-fun, echo=FALSE>>=
insert_fun = function(name) {
read_chunk(lines = capture.output(dump(name, '')), labels = paste(name, 'source', sep = '-'))
}
@
<<insert-lm, echo=FALSE>>=
insert_fun('lm')
@
<<lm-source, eval=FALSE, tidy.opts=list(width.cutoff=30)>>=
@
<<lm-source, eval=FALSE, tidy=TRUE, tidy.opts=list(width.cutoff=30)>>=
@
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment