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

Introduction

This is an R Markdown template for creating a Word document. r phrase

Tables

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

Figures

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

Miscellany

Header fonts

Header 3

Header 4

Header 5
Header 6

Lists

Unordered List:

Ordered List:

  1. Item 1 a. Sub item a a. Sub item b
  2. Item 2

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.



JVAdams/jvamisc documentation built on Aug. 11, 2021, 6:43 a.m.