-
Notifications
You must be signed in to change notification settings - Fork 23
/
html.qmd
79 lines (55 loc) · 1.57 KB
/
html.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
title: "Quarto HTML Basics"
author: "Norah Jones"
date: "March 22nd, 2021"
toc: true
format:
html:
html-math-method: katex
code-tools: true
self-contained: true
execute:
warning: false
---
## Introduction
This a Quarto document. To learn more about Quarto see <https://quarto.org>.
Click the **Code** button in the header to see the full source code of this document.
Here we call the R `summary()` function---the function's output is included immediately below:
```{r}
summary(cars)
```
## Plot Output
You can also embed plots, for example:
```{r}
#| label: fig-pressure
#| fig-cap: "Pressure"
#| code-fold: true
library(ggplot2)
dat <- data.frame(cond = rep(c("A", "B"), each=10),
xvar = 1:20 + rnorm(20,sd=3),
yvar = 1:20 + rnorm(20,sd=3))
ggplot(dat, aes(x=xvar, y=yvar)) +
geom_point(shape=1) +
geom_smooth()
```
Note that the `code-fold: true` parameter was added to the code chunk to hide the code by default (click "Code" above the plot to see the code).
The use of the `label` and `fig-cap` options make this a cross-referenceable figure (see @fig-pressure).
## Interactivity
You can also add interactive plots. For example:
```{r}
#| label: fig-temperatures
#| fig-cap: "New Haven Temperatures"
library(dygraphs)
dygraph(nhtemp) %>%
dyRangeSelector(dateWindow = c("1920-01-01", "1960-01-01"))
```
## Tables
Use the `knitr::kable()` function to print tables as HTML:
```{r}
knitr::kable(head(ggplot2::diamonds))
```
## LaTeX Math
You can also include LaTeX math:
$$
P\left(A=2\middle|\frac{A^2}{B}>4\right)
$$