-
Notifications
You must be signed in to change notification settings - Fork 0
/
math_in_Rmarkdown.Rmd
129 lines (93 loc) · 3.87 KB
/
math_in_Rmarkdown.Rmd
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
title: "Mathematics in R Markdown"
author: "liuc"
date: "2022-10-20"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Mathematics in R Markdown
> https://rpruim.github.io/s341/S19/from-class/MathinRmd.html
此处主要记录一些markdown,尤其是Rmarkdown相关的知识点,方便后续的查询。
### Mathematics in R Markdown
R Pruim
October 19, 2016
Math inside RMarkdown
In side a text chunk, you can use mathematical notation if you surround it by dollar signs $ for “inline mathematics” and $$ for “displayed equations”. Do not leave a space between the $ and your mathematical notation.
Example: $\sum_{n=1}^{10} n^2$ is rendered as ∑10n=1n2.
Example: $$\sum_{n=1}^{10} n^2$$ is rendered as
∑n=110n2
.
The mathematical typesetting is based on LaTeX, so if you need to search for the way to make a particular symbol, include latex in your search. But note: Not all LaTeX macros are available without using additional packages, and those packages likely will only work if you are creating a PDF. On the plus side, if you are working in PDF, you can use additional packages that give much better control and/or easier syntax.
In LaTeX,
macros begin with a backslash (\)
curly braces ({ and }) are used to surround items that are to be considered as one object from LaTeX’s perspective.
Without them, usually the next letter or digit will be used, but that isn’t usually what you want. For example $$\sum_x=1^10 x^2$$ produces
∑x=110x2
Mathematical Notation
Here are some common mathematical things you might use in statistics
x=y $x = y $
x<y $x < y $
x>y $x > y $
x≤y $x \le y $
x≥y $x \ge y $
xn $x^{n}$
xn $x_{n}$
x⎯⎯⎯ $\overline{x}$
x̂ $\hat{x}$
x̃ $\tilde{x}$
ab $\frac{a}{b}$
∂f∂x $\frac{\partial f}{\partial x}$
∂f∂x $\displaystyle \frac{\partial f}{\partial x}$
(nk) $\binom{n}{k}$
x1+x2+⋯+xn $x_{1} + x_{2} + \cdots + x_{n}$
x1,x2,…,xn $x_{1}, x_{2}, \dots, x_{n}$
x=⟨x1,x2,…,xn⟩ \mathbf{x} = \langle x_{1}, x_{2}, \dots, x_{n}\rangle$ (\bm from the bm pacakge would be better)
x∈A $x \in A$
|A| $|A|$
x∈A $x \in A$
A⊂B $x \subset B$
A⊆B $x \subseteq B$
A∪B $A \cup B$
A∩B $A \cap B$
X∼𝖡𝗂𝗇𝗈𝗆(n,π) $X \sim {\sf Binom}(n, \pi)$ (sf for “slide font”)
P(X≤x)=𝚙𝚋𝚒𝚗𝚘𝚖(x,n,π) $\mathrm{P}(X \le x) = {\tt pbinom}(x, n, \pi)$ (tt for “typewriter type”)
P(A∣B) $P(A \mid B)$
P(A∣B) $\mathrm{P}(A \mid B)$ (mathrm for “math roman font”
{1,2,3} $\{1, 2, 3\}$
sin(x) $\sin(x)$
log(x) $\log(x)$
∫ba $\int_{a}^{b}$
(∫baf(x)dx) $\left(\int_{a}^{b} f(x) \; dx\right)$
[∫∞−∞f(x)dx] $\left[\int_{\-infty}^{\infty} f(x) \; dx\right]$
F(x)|ba $\left. F(x) \right|_{a}^{b}$
∑bx=af(x) $\sum_{x = a}^{b} f(x)$
∏bx=af(x) $\prod_{x = a}^{b} f(x)$
limx→∞f(x) $\lim_{x \to \infty} f(x)$
limx→∞f(x) $\displaystyle \lim_{x \to \infty} f(x)$
Greek Letters
αA $\alpha A$ νN $\nu N$
βB $\beta B$ ξΞ $\xi\Xi$
γΓ $\gamma \Gamma$ oO $o O$ (omicron)
δΔ $\delta \Delta$ πΠ $\pi \Pi$
ϵεE $\epsilon \varepsilon E$ ρϱP $\rho\varrho P$
ζZ $\zeta Z \sigma \,\!$ Σ $\sigma \Sigma$
ηH $\eta H$ τT $\tau T$
θϑΘ $\theta \vartheta \Theta$ υΥ $\upsilon \Upsilon$
ιI $\iota I$ ϕφΦ $\phi \varphi \Phi$
κK $\kappa K$ χX $\chi X$
λΛ $\lambda \Lambda$ ψΨ $\psi \Psi$
μM $\mu M$ ωΩ $\omega \Omega$
Aligning equations
If you want a sequence of aligned equations (often very useful for demonstrating algebraic manipulation or for plugging values into equations), use \begin{align*} ... \end{align*}. Separate lines with \\ and use & to mark where things should line up. Note: No dollar signs are needed when you use this method.
Example
This
\begin{align*}
a & = b \\
X &\sim {\sf Norm}(10, 3) \\
5 & \le 10
\end{align*}
### 谢大神书的笔记
> https://bookdown.org/yihui/rmarkdown/
> https://bookdown.org/yihui/rmarkdown-cookbook/