showcode <- TRUE library(knitr) opts_chunk$set(echo=showcode, warning=FALSE, message=FALSE, fig.path='Figs/') if(showcode) { phrase <- "All programming code in [R](http://www.r-project.org/) is shown." } else { phrase <- "For clarity, I don't show the programming code in [R](http://www.r-project.org/), but I'm happy to provide it upon request." } # define two variables to keep track of Table and Figure numbers tabcount <- 1 figcount <- 1
This is an R Markdown template for creating a Word document. r phrase
You can create tables using simple source code (Table r tabcount
) or using the knitr function kable (Table r tabcount + 1
).
Table r tabcount
. First few rows of mtcars using simple source code.
head(mtcars) tabcount <- tabcount + 1
Table r tabcount
. First few rows of mtcars using kable.
knitr::kable(head(mtcars)) tabcount <- tabcount + 1
You create figures, either using the default size (Figure r figcount
) or a custom size (Figure r figcount + 1
).
par(mar=c(4, 4, 1, 1), las=1) plot(cars)
Figure r figcount
. Simple plot of cars, default size.
figcount <- figcount + 1
par(mar=c(4, 4, 1, 1), las=1) plot(cars)
Figure r figcount
. Simple plot of cars, custom size.
figcount <- figcount + 1
Unordered List:
Ordered List:
You can write equations, either inline, $A = \pi*r^{2}$, or centered, $$\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_{i}.$$
You can write bold, italics, superscripts, R^2^, subscripts, X~ij~. You can ~~cross things out~~. And you can draw a horizontal line.
Block quote for a long piece of indented text. When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.