Last active
August 29, 2015 14:11
-
-
Save HenrikBengtsson/f4e8f6fe2af5d6ccbed6 to your computer and use it in GitHub Desktop.
RSP example: A Table
This file contains 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
<%-------------------------------------------------------------- | |
Usage: | |
md <- R.rsp::rfile('table-pandoc.md.rsp', postprocess=FALSE) | |
pdf <- gsub("md$", "pdf", md) | |
system2("pandoc", args=c(normalizePath(md), "-o", pdf)) | |
!pdf # Opens PDF in viewer | |
Requires Pandoc [http://johnmacfarlane.net/pandoc/] and | |
LaTeX, because Pandoc uses LaTeX to generate PDFs. | |
--------------------------------------------------------------%> | |
<% | |
R.utils::use("knitr") | |
options(knitr.table.format="pandoc") | |
kable <- function(...) print(knitr::kable(...)) | |
%> | |
# A Table | |
<% | |
data <- head(datasets::iris) | |
%> | |
<% kable(data) %> | |
_Table: The first <%=nrow(data)%> entries of the iris dataset._ |
This file contains 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
<%-------------------------------------------------------------- | |
Usage: | |
html <- R.rsp::rfile('table.md.rsp') | |
!html # Opens HTML in browser | |
Test on the fly (no installation required): | |
source("http://callr.org/rfile#https://gist.githubusercontent.com/HenrikBengtsson/f4e8f6fe2af5d6ccbed6/raw/table.md.rsp") | |
!html | |
--------------------------------------------------------------%> | |
<% | |
R.utils::use("knitr") | |
options(knitr.table.format="markdown") | |
kable <- function(...) print(knitr::kable(...)) | |
%> | |
# A Table | |
<% | |
data <- head(datasets::iris) | |
%> | |
<% kable(data) %> | |
_Table: The first <%=nrow(data)%> entries of the iris dataset._ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment