---
---

<link rel="stylesheet" href="styles.css" type="text/css">

# <span style="color: red;">Démonstrations de R</span>

Hello, Website!

$A = \pi*r^{2}$

$$E = mc^{2}$$

\usepackage{datetime}
\date{\currenttime}

### <span style="color: red;">Dates</span> [^1]

'format(Sys.Date(), "%B %d, %Y")' &nbsp;[&rArr;](https://www.utf8icons.com/character/8658/rightwards-double-arrow)&nbsp; '`r format(Sys.Date(), "%B %d, %Y")`'

'format(Sys.Date(), "%Y-%B-%d")' &nbsp;[&rArr;](https://www.utf8icons.com/character/8658/rightwards-double-arrow)&nbsp; '`r format(Sys.Date(), "%Y-%B-%d")`'

'format(Sys.Date(), "%Y-%m-%d")' &nbsp;[&rArr;](https://www.utf8icons.com/character/8658/rightwards-double-arrow)&nbsp; '`r format(Sys.Date(), "%Y-%m-%d")`'

'format(Sys.Date(), "%y-%m-%d")' &nbsp;[&rArr;](https://www.utf8icons.com/character/8658/rightwards-double-arrow)&nbsp; '`r format(Sys.Date(), "%y-%m-%d")`'

### <span style="color: red;">Statistiques simples avec R</span>

```{R}
summary((0:9)^2)
```
---

### <span style="color: red;">Graphes simples avec R</span> 

```{R}
# Define cars vector with 5 values
cars <- c(1, 3, 6, 4, 9)

# Define some colors ideal for black & white print
colors <- c("white","grey70","grey90","grey50","black")

# Calculate the percentage for each day, rounded to one 
# decimal place
car_labels <- round(cars/sum(cars) * 100, 1)

# Concatenate a '%' char after each value
car_labels <- paste(car_labels, "%", sep="")

# Create a pie chart with defined heading and custom colors
# and labels
pie(cars, main="Cars", col=colors, labels=car_labels,
   cex=0.8)

# Create a legend at the right   
legend(1.5, 0.5, c("Mon","Tue","Wed","Thu","Fri"), cex=0.8, 
   fill=colors)
```

```{R}
# Get a random log-normal distribution
r <- rlnorm(1000)

# Get the distribution without plotting it using tighter breaks
h <- hist(r, plot=F, breaks=c(seq(0,max(r)+1, .1)))

# Plot the distribution using log scale on both axes, and use
# blue points
plot(h$counts, log="xy", pch=20, col="blue",
	main="Log-normal distribution",
	xlab="Value", ylab="Frequency")
```

### <span style="color: red;">Tableau des lettres grecques en \( \LaTeX \) </span> [^2]

For those of you who don't know your Greek alphabet, it's time to learn it :
name 	symbol 	\( \LaTeX \)

| Prononciation et lettre                           | Prononciation et lettre                            | Prononciation et lettre                      | Prononciation et lettre                            |
|---------------------------------------------------|----------------------------------------------------|----------------------------------------------|----------------------------------------------------| 
| alpha 	  \( \alpha   \  A     \) \alpha    A     | beta     \( \beta       \  B \) 	  \beta     B    | gamma 	\( \gamma  \  \Gamma \) \gamma \Gamma | delta 	\( \delta   \ \Delta  \) \delta   \Delta   |
| epsilon 	\( \epsilon \  E     \) \epsilon  E     |(epsilon) \( \varepsilon \  E \)   	\varepsilon    | zeta  	\( \zeta   \  Z      \) \zeta   Z     | eta   	\( \eta     \ H       \) \eta     \Eta     |
| theta 	  \( \theta   \ \Theta \) \theta   \Theta | iota     \( \iota       \  I \)     \iota     I    | kappa 	\( \kappa  \  K      \) \kappa  K     | lambda 	\( \lambda  \ \Lambda \) \lambda  \Lambda  |
| mu      	\( \mu      \  M     \) \mu       M     | nu 	     \( \nu         \  N \)     \nu       N    | xi 	  \( \xi     \  \Xi    \) \xi    \Xi    | omicron \( \omicron \ O       \) \omicron O        |
| pi 	      \( \pi      \ \Pi    \) \pi      \Pi    | rho 	   \( \rho        \  P \)     \rho      P    | sigma 	\( \sigma  \  \Sigma \) \sigma \Sigma | tau 	  \( \tau     \ T       \) \tau     \Tau     |
| upsilon 	\( \upsilon \  Y     \) \upsilon  Y     | phi 	   \( \phi        \ \Phi \) 	\phi     \Phi  | (phi) 	\( \varphi \) \varphi                 | chi   	\( \chi     \ X       \) \chi     X        |
| psi     	\( \psi     \ \Psi   \) \psi     \Psi   | omega 	 \( \omega      \ \Omega \) \omega   \Omega| -                                            | -                                                  |


### <span style="color: red;">Quelques examples d'utilisation de \( \LaTeX \) dans des documents R</span>

R Markdown allows you to mix text, R code, R output, R graphics, and mathematics in a single document. The mathematics is done using a version of \( \LaTeX \), the premiere mathematics typesetting program. (Our textbook was done entirely in \( \LaTeX \).
Getting in and out of \( \LaTeX \) mode

You enter \( \LaTeX \) mode using $latex (for inline mathematics) or $$latex (for displayed equations). You get back out of \( \LaTeX \) mode using either $ or $$.
Some basic mathematics you might use

Commands in \( \LaTeX \) are preceded by a backslash (\). The simplest commands simply produce a symbol:
Command 	Result
A \cup B \( \quad \) 	\( A \cup B \)
A \cap B 	\( A \cap B \)
x \in A 	\( x \in A \)
5 \pm 2 	\( 5 \pm 2 \)
\log(x) 	\( \log(x) \)
\sin(x) 	\( \sin(x) \)

Other commands take additional inputs (placed inside curly braces {}):
Command 	Result
\sqrt{27} 	\( \sqrt{27} \)
\overline{x} 	\( \overline{x} \)
\frac{k}{n} 	\( \frac{x}{n} \)
\binom{k}{n} 	\( \binom{k}{n} \)
\frac{\partial f}{\partial x} \( \quad \) 	\( \frac{\partial f}{\partial x} \)

The underscore (_) and carrot (^) have special uses in \( \LaTeX \). (Note the use of \displaystyle to get inline mathematics set with larger fonts and more vertical space.)
Command 	Result
x^2 	\( x^2 \)
x_2 	\( x_2 \)
\lim_{x\to\infty} 	\( \lim_{x \to \infty} \)
\displaystyle \lim_{x\to\infty} 	\( \displaystyle \lim_{x \to \infty} \)
\int_0^{\infty} f(x) \; dx 	\( \int_0^{\infty} f(x) \; dx \)
\displaystyle \int_0^{\infty} f(x) \; dx \( \quad \) 	\( \displaystyle \int_0^{\infty} f(x) \; dx \)
```
```

### <span style="color: red;">Modèles d'épidémies avec R</span> [^3]

#### <span style="color: red;">Exemple : Modèle SIR Model avec une dynamique vitale (Un Groupe)</span>

```
param <- param.dcm(inf.prob = 0.2, act.rate = 5,
rec.rate = 1/3, a.rate = 1/90, ds.rate = 1/100,
di.rate = 1/35, dr.rate = 1/100)
init <- init.dcm(s.num = 500, i.num = 1, r.num = 0)
control <- control.dcm(type = "SIR", nsteps = 500)
mod2 <- dcm(param, init, control)
mod2
plot(mod2)
```


[^1]: [Codage des dates](shttps://stackoverflow.com/questions/23449319/yaml-current-date-in-rmarkdown)
[^2]: [Markdown et LaTeX](http://www.calvin.edu/~rpruim/courses/m343/F12/RStudio/LatexExamples.html)
[^3]: [Modèle SIR](https://cran.r-project.org/web/packages/EpiModel/EpiModel.pdf)


***
##### [2020-03-24 &nbsp;&nbsp;&nbsp; © 2020 axul.org](http://axul.org) &nbsp;&nbsp;&nbsp; [licence cc-by-sa](http://creativecommons.org) &nbsp;&nbsp;&nbsp; [Source](R.Rmd) &nbsp;&nbsp;&nbsp; [W3C](http://validator.w3.org/) &nbsp;&nbsp;&nbsp; [HTML5](https://fr.wikipedia.org/wiki/HTML5) &nbsp;&nbsp;&nbsp; [CSS](http://jigsaw.w3.org/css-validator/)
***
