This tutorial is based on R Markdown Cookbook by Xie et al. (2018). See the link
library(bookdown)
library(DiagrammeR)
library(equatiomatic)
library(kableExtra)
library(xtable)
library(pander)
library(corrplot)
## corrplot 0.92 loaded
DiagrammeR::grViz("digraph {
graph [layout = dot, rankdir = TB]
node [shape = rectangle]
rec1 [label = '1. Introduction']
rec2 [label = '2. Exploratory Analysis']
rec3 [label = '3. Predictive Analysis']
rec4 [label = '4. Recommendations/Conclusions']
# edge definitions with the node IDs
rec1 -> rec2 -> rec3 -> rec4
}",
height = 500)
print(xtable(head(iris), caption = "My table using xtable package", label = "xtabletab"), comment = FALSE,
caption.placement = "top", type = "html")
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species | |
|---|---|---|---|---|---|
| 1 | 5.10 | 3.50 | 1.40 | 0.20 | setosa |
| 2 | 4.90 | 3.00 | 1.40 | 0.20 | setosa |
| 3 | 4.70 | 3.20 | 1.30 | 0.20 | setosa |
| 4 | 4.60 | 3.10 | 1.50 | 0.20 | setosa |
| 5 | 5.00 | 3.60 | 1.40 | 0.20 | setosa |
| 6 | 5.40 | 3.90 | 1.70 | 0.40 | setosa |
dat <- head(iris)
knitr::kable(dat, caption = "My table using knitr::kable",
booktabs = T, label = "kabletable")
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
|---|---|---|---|---|
| 5.1 | 3.5 | 1.4 | 0.2 | setosa |
| 4.9 | 3.0 | 1.4 | 0.2 | setosa |
| 4.7 | 3.2 | 1.3 | 0.2 | setosa |
| 4.6 | 3.1 | 1.5 | 0.2 | setosa |
| 5.0 | 3.6 | 1.4 | 0.2 | setosa |
| 5.4 | 3.9 | 1.7 | 0.4 | setosa |
dat <- head(iris)
kab <- knitr::kable(dat, caption = "My table using kable classic",
booktabs = T, label = "kabletable")
kable_classic_2(kab, full_width = F)
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
|---|---|---|---|---|
| 5.1 | 3.5 | 1.4 | 0.2 | setosa |
| 4.9 | 3.0 | 1.4 | 0.2 | setosa |
| 4.7 | 3.2 | 1.3 | 0.2 | setosa |
| 4.6 | 3.1 | 1.5 | 0.2 | setosa |
| 5.0 | 3.6 | 1.4 | 0.2 | setosa |
| 5.4 | 3.9 | 1.7 | 0.4 | setosa |
plot(cars)
Figure 4.1: Distance vs. speed
fit <- lm(mpg ~ hp, mtcars)
# Show the linear model
equatiomatic::extract_eq(fit)
\[ \operatorname{mpg} = \alpha + \beta_{1}(\operatorname{hp}) + \epsilon \]
# display the actual coefficients
equatiomatic::extract_eq(fit, use_coefs = TRUE)
\[ \operatorname{\widehat{mpg}} = 30.1 - 0.07(\operatorname{hp}) \]
plot(mpg ~ hp, mtcars)
Figure 4.2: MPG (miles per gallon) vs. HP (Horse Power
library(bookdown)
library(DiagrammeR)
library(equatiomatic)
library(kableExtra)
library(xtable)
library(pander)
library(corrplot)
DiagrammeR::grViz("digraph {
graph [layout = dot, rankdir = TB]
node [shape = rectangle]
rec1 [label = '1. Introduction']
rec2 [label = '2. Exploratory Analysis']
rec3 [label = '3. Predictive Analysis']
rec4 [label = '4. Recommendations/Conclusions']
# edge definitions with the node IDs
rec1 -> rec2 -> rec3 -> rec4
}",
height = 500)
print(xtable(head(iris), caption = "My table using xtable package", label = "xtabletab"), comment = FALSE,
caption.placement = "top", type = "html")
dat <- head(iris)
knitr::kable(dat, caption = "My table using knitr::kable",
booktabs = T, label = "kabletable")
dat <- head(iris)
kab <- knitr::kable(dat, caption = "My table using kable classic",
booktabs = T, label = "kabletable")
kable_classic_2(kab, full_width = F)
plot(cars)
fit <- lm(mpg ~ hp, mtcars)
# Show the linear model
equatiomatic::extract_eq(fit)
# display the actual coefficients
equatiomatic::extract_eq(fit, use_coefs = TRUE)
plot(mpg ~ hp, mtcars)
U of Windsor, odette@uwindsor.ca↩︎