Processing math: 100%



[∇] [@] Introduction à R et RStudio

Version 2020-10-18

Licence cc-by-sa ModLibre.info sauf autres indications

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


Hello, Website!

Dates 1

‘format(Sys.Date(), “%B %d, %Y”)’    ‘octobre 18, 2020’

‘format(Sys.Date(), “%Y-%B-%d”)’    ‘2020-octobre-18’

‘format(Sys.Date(), “%Y-%m-%d”)’    ‘2020-10-18’

‘format(Sys.Date(), “%y-%m-%d”)’    ‘20-10-18’

Statistiques simples avec R

summary((0:9)^2)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.25   20.50   28.50   45.75   81.00



[∇] [Δ] Graphes simples avec R 2

# 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)

# 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")
## Warning in xy.coords(x, y, xlabel, ylabel, log): 463 y values <= 0 omitted from
## logarithmic plot



[∇] [Δ] Quelques examples d’utilisation de LATEX dans des documents R

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=πr2

E=mc2



[∇] [Δ] Tableau des lettres grecques en LATEX 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 α A A beta β B B gamma γ Γ delta δ Δ
epsilon ϵ E E (epsilon) ε E zeta ζ Z Z eta η H
theta θ Θ iota ι I I kappa κ K K lambda λ Λ
mu μ M M nu ν N N xi ξ Ξ omicron ο O O
pi π Π rho ρ P P sigma σ Σ tau τ T
upsilon υ Y Y phi ϕ Φ (phi) φ chi χ X X
psi ψ Ψ omega ω Ω - -



[∇] [Δ] Modèles d’épidémies avec R 4

Exemple : Modèle SIR Model avec une dynamique vitale (Un Groupe)

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)



[@] [Δ] Fin



  1. Codage des dates

  2. Producing Simple Graphs with R © 2006-16 by Frank McCown

  3. Markdown et LaTeX

  4. Modèle SIR (Licence GPL-3)