1 + 10[1] 11
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.
When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
1 + 10[1] 11
You can add options to executable code like this
[1] 4
The echo: false option disables the printing of code (only output is displayed).
il y a des formules en ligne et des formules en display
En ligne \(\int_0^{\infty}e^{-x2}dx\)
En display \[\int_0^{\infty}e^{-x2}dx=\frac{\sqrt{\pi}}{2}\]
On suppose que \(X\sim \mathcal{N}(100,20)\)et on veut calculer \(\Pr(X > 120)\)
pnorm(120,100,20,lower.tail = FALSE)[1] 0.1586553
Comment faire pour que le résultat de ce calcul soit transparent et s’affiche directement dans mon document?
La probabilité que \(( X > 120)\) est ‘r round(pnorm(120,100,20,lower.tail = FALSE),2)’.
![Image à insérer]
#Tidyverse
library(tidyverse)── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.4 ✔ tidyr 1.3.1
✔ purrr 1.0.4
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
120|>pnorm(100,20,lower.tail = FALSE)|>round(2)|>sqrt()[1] 0.4
mtcars|>data()
df<-mtcars
df$mpg #Méthode à l'ancienne [1] 21.0 21.0 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 17.8 16.4 17.3 15.2 10.4
[16] 10.4 14.7 32.4 30.4 33.9 21.5 15.5 15.2 13.3 19.2 27.3 26.0 30.4 15.8 19.7
[31] 15.0 21.4
df|>select(mpg) #Méthode moderne mpg
Mazda RX4 21.0
Mazda RX4 Wag 21.0
Datsun 710 22.8
Hornet 4 Drive 21.4
Hornet Sportabout 18.7
Valiant 18.1
Duster 360 14.3
Merc 240D 24.4
Merc 230 22.8
Merc 280 19.2
Merc 280C 17.8
Merc 450SE 16.4
Merc 450SL 17.3
Merc 450SLC 15.2
Cadillac Fleetwood 10.4
Lincoln Continental 10.4
Chrysler Imperial 14.7
Fiat 128 32.4
Honda Civic 30.4
Toyota Corolla 33.9
Toyota Corona 21.5
Dodge Challenger 15.5
AMC Javelin 15.2
Camaro Z28 13.3
Pontiac Firebird 19.2
Fiat X1-9 27.3
Porsche 914-2 26.0
Lotus Europa 30.4
Ford Pantera L 15.8
Ferrari Dino 19.7
Maserati Bora 15.0
Volvo 142E 21.4
df<-df|>
mutate(lcentkm=100*3.78541/(mpg*1.60934)) |> relocate(lcentkm, .before = everything())df|> ggplot(aes(x=lcentkm))+ geom_histogram(binwidth = 1,fill = "#FF00FF", color = "black")+labs(title = "Histogramme de la consommation (L/100 km)", x = "Consommation (L/100 km)", y ="Nombre de modèles")