Here is how you can make a table in GFM format using knitr + ascii
render_gfm()
gfm_table <- function(x, ...) {
require(ascii)
y <- capture.output(print(ascii(x, ...), type = "org"))
# substitute + with | for table markup
\documentclass{article} | |
<<hook-printfun, echo=FALSE>>= | |
knit_hooks$set(printfun = function(before, options, envir) { | |
if (before) return() | |
txt = capture.output(dump(options$printfun, '')) | |
## reformat if tidy=TRUE | |
if (options$tidy) txt = formatR::tidy.source(text = txt, output = FALSE)$text.tidy | |
con = textConnection(txt) | |
on.exit(close(con)) |
Here is how you can make a table in GFM format using knitr + ascii
render_gfm()
gfm_table <- function(x, ...) {
require(ascii)
y <- capture.output(print(ascii(x, ...), type = "org"))
# substitute + with | for table markup
% Using Pandoc and knitR to Write Reproducible Documents % Ramnath Vaidyanathan % 23-Mar-2012
ro tidy = F, fig.width = 4.5, fig.height = 4.5, dev = 'Cairo_png' or
options(width = 75)
read_chunk('ext-chunks.R')
# opts_knit$set(upload.fun = imgur_upload)
This script has been adapted from a post on LA Times
#!/bin/sh | |
####################################################### | |
# UNIX TREE # | |
# Version: 2.3 # | |
# File: ~/apps/tree/tree.sh # | |
# # | |
# Displays Structure of Directory Hierarchy # | |
# ------------------------------------------------- # | |
# This tiny script uses "ls", "grep", and "sed" # | |
# in a single command to show the nesting of # |
# GET LIST OF INSTALLED PACKAGES | |
pkgs <- installed.packages(priority='NA')[,'Package'] | |
save(pkgs, file="installed_pkgs.rda") | |
# Install the most recent version of R: | |
# Download the most recent version of R from The Comprehensive R Archive Network (CRAN) | |
# To wipe the old R version | |
rm -rf /Library/Frameworks/R.framework /Applications/R.app | |
rm -rf /Library/Receipts/R-* |
% set slide background to a specified color | |
\newcommand{\setbgcol}[1]{\setbeamercolor{background canvas}{bg = #1}} | |
% set slide background to a specified pic | |
\newcommand{\setbgpic}[1]{ | |
\usebackgroundtemplate{ | |
\includegraphics[width=\paperwidth]{#1} | |
} | |
} |
{% extends "!layout.html" %} | |
{% block rootrellink %} | |
<li><a href="{{ pathto('index') }}">home</a>| </li> | |
<li><a href="{{ pathto('search') }}">search</a>| </li> | |
<li><a href="{{ pathto('contents') }}">documentation </a> »</li> | |
{% endblock %} | |
# Generate PDF for a Pid | |
gen_pdf <- function(sdf){ | |
rnw_file <- sprintf("%s.rnw", unique(sdf$Pid)) | |
tex_file <- sub('.rnw$', '.tex$', rnw_file) | |
file.copy('template.Rnw', rnw_file) | |
Sweave(rnw_file) | |
tools::texi2pdf(tex_file, clean = TRUE, quiet = TRUE) | |
unlink(c(rnw_file, tex_file)) | |
} |