knitr::opts_chunk$set(echo = TRUE, prompt = TRUE, fig.align = 'center') knitr::opts_knit$set(global.par = TRUE)
library(knitr)
For more information see the accessr site on GitHub
$$ \begin{eqnarray} T = \left{\begin{array}{ll} \overline{X} & \mbox{ with probability } 1 - 1/n \,, \ \overline{X} + n & \mbox{ with probability } 1/n \,. \ \end{array}\right. \end{eqnarray} $$
[ \begin{aligned} P(X \leq x) &= P(F^{-1}(U) \leq x) \ &= P(F(F^{-1}(U)) \leq F(x)) \ &= P(U \leq F(x)) = F(x). \end{aligned} ]
Tips (prompted by issues when creating Word output):
$$ ... $$
. Otherwise, the maths is ignored.\text{}
or \mbox{}
for text in an maths environment. (\rm{}
causes problems.)oldpar <- par(mar = c(4, 4, 1, 1))
plot(1:10, 1:10, pch = 1:10, xlab = "x", ylab = "y")
include_graphics(system.file(package = "accessr", "examples", "plot.png"))
The table will only appear if both of the packages dplyr
or huxtable
are installed. The huxtable
code is hidden because it is lengthy. Of course, there are many other ways to create tables in R markdown.
got_dplyr <- requireNamespace("dplyr", quietly = TRUE) got_huxtable <- requireNamespace("huxtable", quietly = TRUE) got_both <- got_dplyr && got_huxtable
library(dplyr, warn.conflicts = FALSE) library(huxtable, warn.conflicts = FALSE) row1 <- c("1", "A", "36", "24") row2 <- c("", "B", "24", "16") row3 <- c("2", "A", "4", "16") row4 <- c("", "B", "16", "64") blank <- rep("", 4) x <- as.data.frame(rbind(row1, row2, row3, row4)) colnames(x) <- c("clinic", "drug", "success (S)", "failure (F)") x_hux <- x %>% as_hux() %>% set_top_border(c(2, 4), everywhere, brdr(1, "solid", "black")) %>% set_right_border(everywhere, 1:3, brdr(1, "solid", "black")) %>% set_align(everywhere, 1:4, "center") %>% set_width(0.8) %>% set_height(0.001) %>% set_number_format(everywhere, everywhere, 0) %>% set_all_padding(3) %>% set_outer_padding(0) %>% set_caption("Table caption") x_hux
echo
# hide = TRUE to hide certain parts # hide = FALSE to include them hide <- params$hide
``{asis, echo = !hide}
This text will appear only if
params$hide = FALSE`
```{asis, echo = hide} Setting `params$hide = TRUE` can be used to hide content
eval
``{asis, echo = hide}
The figure is missing because
params$hide = TRUE`
```r plot(1:10, 1:10, pch = 1:10, xlab = "x", ylab = "y")
par(oldpar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.