Mon premier document Quarto

Auteur·rice

Valentine Sanchez

Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.

Running Code

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 + 1
[1] 2

You can add options to executable code like this

1 + 1
[1] 2
x<-1:20 # une liste avec tous les nombres de 1 à 20 
# Une liste de dates de 1970 à 2026 années bisxtiles
dates<-seq(1970,2026,4)
sum(x) # sommes des nombres qui se trouvent dans la liste x
[1] 210

The echo: false option disables the printing of code (only output is displayed).

Une manière plus moderne

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.0     ✔ readr     2.2.0
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.2     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.2
✔ purrr     1.2.1     
── 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
data(mtcars)
data_frame(mtcars)
Warning: `data_frame()` was deprecated in tibble 1.1.0.
ℹ Please use `tibble()` instead.
# A tibble: 32 × 11
     mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
 1  21       6  160    110  3.9   2.62  16.5     0     1     4     4
 2  21       6  160    110  3.9   2.88  17.0     0     1     4     4
 3  22.8     4  108     93  3.85  2.32  18.6     1     1     4     1
 4  21.4     6  258    110  3.08  3.22  19.4     1     0     3     1
 5  18.7     8  360    175  3.15  3.44  17.0     0     0     3     2
 6  18.1     6  225    105  2.76  3.46  20.2     1     0     3     1
 7  14.3     8  360    245  3.21  3.57  15.8     0     0     3     4
 8  24.4     4  147.    62  3.69  3.19  20       1     0     4     2
 9  22.8     4  141.    95  3.92  3.15  22.9     1     0     4     2
10  19.2     6  168.   123  3.92  3.44  18.3     1     0     4     4
# ℹ 22 more rows
mtcars|>tibble()|>select(1,2)
# A tibble: 32 × 2
     mpg   cyl
   <dbl> <dbl>
 1  21       6
 2  21       6
 3  22.8     4
 4  21.4     6
 5  18.7     8
 6  18.1     6
 7  14.3     8
 8  24.4     4
 9  22.8     4
10  19.2     6
# ℹ 22 more rows
mtcars|>tibble()|>select(mpg,cyl)|>filter(mpg<15)
# A tibble: 5 × 2
    mpg   cyl
  <dbl> <dbl>
1  14.3     8
2  10.4     8
3  10.4     8
4  14.7     8
5  13.3     8
tbmtcars<-mtcars|>tibble()

tbmtcars|>ggplot(aes(cyl,mpg))+geom_point(col="red")+ggtitle("mpg vs. cylindré")+xlab("Cylindrée")+ylab("mpg")

Créer des variables