---
---


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

<span id="Initial"><br><br></span>

# <span><a href="#Graphes">[&nabla;]</a></span> <span><a href="#Final">[@]</a></span> <span style="color: red;">Introduction à R et RStudio</span>

## Version 2020-10-18
## Licence cc-by-sa ModLibre.info sauf autres indications<br>

#### NB : Copiez les instructions que vous voulez tester dans une version récente de R ou RStudio

<span id="Hello"><br></span>

### Hello, Website!

\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 id="Graphes"><br><br></span>

# <span><a href="#LaTeX">[&nabla;]</a></span> <span><a href="#Initial">[&Delta;]</a></span> <span style="color: red;">Graphes simples avec R</span> [^2]

```{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 id="LaTeX"><br><br></span>

# <span><a href="#Grec">[&nabla;]</a></span> <span><a href="#Graphes">[&Delta;]</a></span> <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 \)...)
(à compléter).

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

$$E = mc^{2}$$

<span id="Grec"><br><br></span>

# <span><a href="#Epidemie">[&nabla;]</a></span> <span><a href="#LaTeX">[&Delta;]</a></span> <span style="color: red;">Tableau des lettres grecques en \( \LaTeX \) </span> [^3]

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 id="Epidemie"><br><br></span>

# <span><a href="#Final">[&nabla;]</a></span> <span><a href="#Grec">[&Delta;]</a></span> <span style="color: red;">Modèles d'épidémies avec R</span> [^4]

#### <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]: [Producing Simple Graphs with R](https://sites.harding.edu/fmccown/r/) © 2006-16 by Frank McCown
[^3]: [Markdown et LaTeX](http://www.calvin.edu/~rpruim/courses/m343/F12/RStudio/LatexExamples.html)
[^4]: [Modèle SIR](https://cran.r-project.org/web/packages/EpiModel/EpiModel.pdf) (Licence GPL-3)

<span id="Final"><br><br></span>

# <span><a href="#Initial">[@]</a></span> <span><a href="#Epidemie">[&Delta;]</a></span> <span style="color: red;">Fin</span>

***
##### [2020-10-18 &nbsp;&nbsp;&nbsp; © 2020 ModLibre.info](http://ModLibre.info) &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/)
***
