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")

Question 1

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")

a) Part A of the question here

# 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.

$s_{{b_0}} = \sqrt{MSE[{\dfrac{1}{n}+\dfrac{\bar{X}^2}{\sum{(X_i - \bar{X})^2}}}]} = r signif(Q1_sb0,3)$

b) Part B of the question here

Question 2

Plot Figures With Centered Captions

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")

Plot Figures With Centered Captions

kable(ggplot2::diamonds[1:10,])
jpfxns2::adaptiveCenterCaption(chunckName="Draw-Table", caption = "First 10 records in the diamonds table from ggplot2.", capFxn = "TabNum")

Code Appendix

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)


jacpete/jpfxns2 documentation built on May 10, 2020, 9:15 p.m.