library(knitr) library(tidyverse) library(captioner) # devtools::install_github("jacpete/jpfxns2") library(jpfxns2)
opts_chunk$set(echo = TRUE) options(knitr.duplicate.label = 'allow')
# setwd(dirname(rstudioapi::getSourceEditorContext()$path)) knitr::opts_knit$set(root.dir = getwd() )
figNum <- captioner(prefix="Fig.") TabNum <- captioner(prefix="Table")
Copy the question here?
# All of initial R code or loading the data needed to answer the question goes here # Adopt a naming protocol to keep track such as: # Q1_n <- 10 # Q1_b1estimate <- 711 # Q1_b1stderr <- 143 # GPA <- readr::read_csv("GPA.csv")
# Code specific to a part goes here # I suggest adding a part identifier to your variable names such as: # Q1A_SSxy <- sum((GPA$ACT - Q2_Xbar)*(GPA$GPA - Q2_Ybar)) Q1_sb0 <- 12.85683
Answers can then by typed below each part.
r signif(ggplot2::diamonds$depth[4],3)
}. Note the code for formatting to three significant figures. If you want to use a percent sign in the highlighted area you have to escape it like: \hl{The 95\% CI is ...}
Equations are typed in latex format and have to be surrounded by dollar signs $
$s_{{b_0}} = \sqrt{MSE[{\dfrac{1}{n}+\dfrac{\bar{X}^2}{\sum{(X_i - \bar{X})^2}}}]} = r signif(Q1_sb0,3)
$
Figures are captioned by plotting in one chunck and then providing a caption in the following chunk with the option results="asis"
.
qplot(carat, price, data = ggplot2::diamonds)
jpfxns2::adaptiveCenterCaption(chunckName="Plot-Caret-Price", caption = "This is caption 1", capFxn = "figNum")
kable(ggplot2::diamonds[1:10,])
jpfxns2::adaptiveCenterCaption(chunckName="Draw-Table", caption = "First 10 records in the diamonds table from ggplot2.", capFxn = "TabNum")
RmdName <- knitr::current_input() knitr::purl(RmdName, documentation = 1) RfileName <- str_sub(RmdName, end = -3)
if (file.exists(RfileName)) #Delete file if it exists file.remove(RfileName)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.