diff --git a/.Rprofile b/.Rprofile deleted file mode 100644 index 81b960f..0000000 --- a/.Rprofile +++ /dev/null @@ -1 +0,0 @@ -source("renv/activate.R") diff --git a/.github/workflows/bookdown-build-and-deploy.yml b/.github/workflows/bookdown-build-and-deploy.yml index 61fd4e7..5d4292d 100644 --- a/.github/workflows/bookdown-build-and-deploy.yml +++ b/.github/workflows/bookdown-build-and-deploy.yml @@ -1,16 +1,16 @@ -name: Déploiement de parcours_r_module_datavisualisation - -on: - push: - branches: - - main - - master - - workflow_dispatch: - -jobs: - build-and-deploy-bookdown: - name: Build and bookdown - uses: MTES-MCT/parcours-r/.github/workflows/bookdown-build-and-deploy.yml@master - with: - r_version: '4.0.4' +name: Déploiement de parcours_r_module_datavisualisation + +on: + push: + branches: + - main + - master + workflow_dispatch: + +jobs: + build-and-deploy-bookdown: + name: Build and bookdown + uses: MTES-MCT/parcours-r/.github/workflows/bookdown-build-and-deploy.yml@master + with: + r_version: '4.2.2' + diff --git a/.github/workflows/bookdown-build.yml b/.github/workflows/bookdown-build.yml index dbecc87..434be74 100644 --- a/.github/workflows/bookdown-build.yml +++ b/.github/workflows/bookdown-build.yml @@ -1,15 +1,15 @@ -name: Test compilation de parcours_r_module_datavisualisation - -on: - pull_request: - branches: [main, master, dev] - types: [opened, synchronize] - - workflow_dispatch: - -jobs: - build-bookdown: - name: Build bookdown - uses: MTES-MCT/parcours-r/.github/workflows/bookdown-build.yml@master - with: - r_version: '4.0.4' +name: Test compilation de parcours_r_module_datavisualisation + +on: + pull_request: + branches: [main, master, dev] + types: [opened, synchronize] + + workflow_dispatch: + +jobs: + build-bookdown: + name: Build bookdown + uses: MTES-MCT/parcours-r/.github/workflows/bookdown-build-from-desc.yml@master + with: + r_version: '4.2.2' diff --git a/.github/workflows/deploy_bookdown.yml b/.github/workflows/deploy_bookdown.yml deleted file mode 100644 index b2f7c68..0000000 --- a/.github/workflows/deploy_bookdown.yml +++ /dev/null @@ -1,88 +0,0 @@ -on: - push: - branches: - - main - - master - -env: - RENV_PATHS_ROOT: ~/.local/share/renv - - -name: renderbook - -jobs: - bookdown: - name: Render-Book - runs-on: macOS-latest - steps: - - - name: Checkout repo - uses: actions/checkout@v2 - - - name: Setup R - uses: r-lib/actions/setup-r@master - with: - r-version: '4.0.4' - - - name: Install pandoc - run: | - brew install pandoc - - - name: Cache Renv packages - uses: actions/cache@v2 - with: - path: $HOME/.local/share/renv - key: r-${{ hashFiles('renv.lock') }} - restore-keys: r- - - - name: Cache bookdown results - uses: actions/cache@v2 - with: - path: _bookdown_files - key: bookdown-${{ hashFiles('**/*Rmd') }} - restore-keys: bookdown- - - - name: Install gouvdown fonts to mac os - run: | - Rscript -e 'install.packages("remotes");remotes::install_github("spyrales/gouvdown.fonts")' - cp /Users/runner/work/parcours_r_module_datavisualisation/parcours_r_module_datavisualisation/renv/library/R-4.0/x86_64-apple-darwin17.0/gouvdown.fonts/resources/fonts/spectral/desktop/truetype/*.ttf /Library/Fonts/ - cp /Users/runner/work/parcours_r_module_datavisualisation/parcours_r_module_datavisualisation/renv/library/R-4.0/x86_64-apple-darwin17.0/gouvdown.fonts/resources/fonts/marianne/truetype/*.ttf /Library/Fonts/ - - - name: Install packages - run: | - install.packages("renv") - renv::restore() - shell: Rscript {0} - - - name: Build site - run: Rscript -e 'bookdown::render_book("index.Rmd", quiet = TRUE)' - - - uses: actions/upload-artifact@v1 - with: - name: _book - path: _book/ - -# Need to first create an empty gh-pages branch -# see https://pkgdown.r-lib.org/reference/deploy_site_github.html -# and also add secrets for a GH_PAT and EMAIL to the repository -# gh-action from Cecilapp/GitHub-Pages-deploy - checkout-and-deploy: - runs-on: ubuntu-latest - needs: bookdown - steps: - - name: Checkout - uses: actions/checkout@master - - name: Download artifact - uses: actions/download-artifact@v1.0.0 - with: - # Artifact name - name: _book # optional - # Destination path - path: _book # optional - - name: Deploy to GitHub Pages - uses: Cecilapp/GitHub-Pages-deploy@master - env: - GITHUB_TOKEN: ${{ secrets.GH_PAT }} # https://github.com/settings/tokens - with: - build_dir: _book # "_site/" by default - email: ${{ secrets.EMAIL }} # must be a verified email diff --git a/.github/workflows/rstudio-image-build.yml b/.github/workflows/rstudio-image-build.yml index 77e3cf3..e1360c6 100644 --- a/.github/workflows/rstudio-image-build.yml +++ b/.github/workflows/rstudio-image-build.yml @@ -5,10 +5,11 @@ on: branches: - main - master + - dev paths: - .github/workflows/rstudio-image-build.yml - Dockerfile - - renv.lock + - DESCRIPTION pull_request: types: [opened, synchronize] @@ -16,10 +17,11 @@ on: paths: - .github/workflows/rstudio-image-build.yml - Dockerfile - - renv.lock + - DESCRIPTION workflow_dispatch: jobs: build-rstudio-image: uses: MTES-MCT/parcours-r/.github/workflows/rstudio-image-build.yml@master + diff --git a/.gitignore b/.gitignore index 5760704..dce3a28 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,9 @@ _book _bookdown_files _book.zip -montableau.png \ No newline at end of file +montableau.png +Valorisation** +extdata/Carte_EPCI_France.RData +extdata/ODD.RData +extdata/rpls_aggrege.RData +extdata/rpls_aggrege_large.RData \ No newline at end of file diff --git a/01b-get_started.Rmd b/01b-get_started.Rmd index 3631564..13fd712 100644 --- a/01b-get_started.Rmd +++ b/01b-get_started.Rmd @@ -2,41 +2,10 @@ ## Créer un projet sous Rstudio pour vous permettre de recencer vos travaux. -Pourquoi travailler avec les projets Rstudio plutôt que les scripts R ? - -- Cela permet la portabilité : le répertoire de travail par défaut d'un projet est le répertoire où est ce projet. Si vous transmettez celui-ci à un collègue, le fait de lancer un programme ne dépend pas de l'arborescence de votre machine. - -> **Fini les `setwd("chemin/qui/marche/uniquement/sur/mon/poste")` !** - - -- Toujours sur la portabilité, un projet peut être utilisé avec un outil comme `renv` qui va vous intégrer en interne au projet l'ensemble des packages nécessaires au projet. Cela permet donc à votre collègue à qui vous passez votre projet de ne pas avoir à les installer et, surtout, si vous mettez à jour votre environnement R, votre projet restera toujours avec les versions des packages avec lesquelles vous avez fait tourner votre projet à l'époque. Cela évite d'avoir à subir les effets d'une mise à jour importante d'un package qui casserait votre code. - -Pour activer `renv` sur un projet, il faut l'installer avec `install.packages("renv")`. -Pour intialiser la sauvegarde des packages employés dans le projet, il faut utiliser -`renv::init()` -Les packages chargés dans le projet sont enregistrés dans un sous-dossier dédié. -En cours de travail sur le projet, la commande `renv::snapshot()` permet de faire une sauvegarde, la commande `renv::restore()` permet de charger la dernière sauvegarde. - -[En savoir plus sur renv](https://blog.rstudio.com/2019/11/06/renv-project-environments-for-r/) - - - -- Cela permet de se forcer à travailler en mode projet : on intègre à un seul endroit tout ce qui est lié à un projet : données brutes, données retravaillées, scripts, illustrations, documentations, publications... et donc y compris les packages avec `renv`. - -- On peut travailler sur plusieurs projets en même temps, Rstudio ouvre autant de sessions que de projet dans ce cas. - -- Les projets Rstudio intègrent une interface avec les outils de gestion de version git et svn. Cela veut dire que vous pouvez versionner votre projet et l'héberger simplement comme répertoire sur des plateformes de gestion de code telle que github ou gitlab. - -**Pour créer un projet : ** - -- Cliquez sur *Project* en haut à droite puis *New Project*. - -![](images/creerprojet1.png){#id .class width=500} - -- Cliquez sur *New Directory*. - -![](images/creerprojet2.png){#id .class width=500} - +```{r collecte prez projet rstudio, warning=FALSE, echo=FALSE, results='asis'} +# Utilisation du chapitre de présentation des projets RStudio présent dans https://github.com/MTES-MCT/parcours-r +cat(text = stringi::stri_read_lines("https://raw.githubusercontent.com/MTES-MCT/parcours-r/master/parties_communes/bien_commencer.Rmd", encoding = "UTF-8"), sep = '\n') +``` ## Intégrer vos données diff --git a/03-l-aesthetic.Rmd b/03-l-aesthetic.Rmd index c418181..e201976 100644 --- a/03-l-aesthetic.Rmd +++ b/03-l-aesthetic.Rmd @@ -57,25 +57,8 @@ Pour plus d'informations: https://github.com/daattali/colourpicker. ## Exercice 1 -> A partir des données de la table rpls_aggrege_large (dans extdata/rpls_aggrege_large.RData), -> -> créer un nuage de point (un point par EPCI, filtre sur la variable TypeZone) entre : -> -> - le % de parc social de moins de 5 ans ('Parc_de_moins_de_5_ans_pourcent'); -> -> - et le pourcentage de logement avec un DPE ges de classe A, B ou C ('DPE_GES_classe_ABC_pourcent'); -> -> - et une couleur différente pour distinguer les epci de la région PDL (booléen 'epci_2017_52'). - -Le résultat attendu : - -```{r eval=T,echo=F,warning=F} -ggplot(data = rpls_aggrege_large %>% - filter(TypeZone == "Epci")) + - geom_point(aes(x = Parc_de_moins_de_5_ans_pourcent, - y = DPE_GES_classe_ABC_pourcent, - color = epci_2017_52), - alpha = .5, - size = .5 - ) +```{r mod5_exo1, child=charge_exo('m5', 'exo1.rmd'), echo=FALSE} + ``` + + diff --git a/04-les-formes-geometriques.Rmd b/04-les-formes-geometriques.Rmd index 84d76e1..d7263d3 100644 --- a/04-les-formes-geometriques.Rmd +++ b/04-les-formes-geometriques.Rmd @@ -2,8 +2,8 @@ Pour spécifier le type de représentation que l'on souhaite, il faut utiliser les fonctions de la forme **geom_XX** -Le tableau ci-dessous présente quelques représentations graphiques classiques. -Il en existe un grand nombre que l'on peut retrouver grâce à l'aide +Le tableau ci-dessous présente quelques représentations graphiques classiques. +Il en existe un grand nombre que l'on peut retrouver grâce à l'aide. ```{r fg4_1, echo=T,eval=F,warning = FALSE,message = FALSE} help.search("^geom_", package = "ggplot2") @@ -19,6 +19,10 @@ geom_histogram() | Histogramme | x, fill, linetype, color, alpha, size, weight geom_boxplot() | Boîte à moustaches | x, alpha, colour, fill, group, linetype, shape, size, weight geom_density() | Courbe de densité | x, y, alpha, color, fill, linetype, size, weight +La feuille de triche de `{ggplot2}` peut aider aussi à avoir une idée du geom qu'on cherche. + +![Feuille de triche ggplot2](images/cheat_sheet_ggplot2.png "Accéder à la feuille de triche ggplot2 depuis RStudio"){#id .class width=716} + Il y a deux types de diagramme en barres : `geom_bar()` et `geom_col()`. `geom_bar()` ne prend pas de variable `y` dans le mapping, la hauteur des barres est proportionnelle à l'occurrence de chaque modalité de `x`. On peut pondérer chaque occurrence de `x` par une autre variable à indiquer au niveau du paramètre `weight`. diff --git a/06-l-habillage-simple.Rmd b/06-l-habillage-simple.Rmd index 2914570..269f386 100644 --- a/06-l-habillage-simple.Rmd +++ b/06-l-habillage-simple.Rmd @@ -7,14 +7,14 @@ Chaque nouvel élément graphique est à rajouter sous forme de layer. Ici, nous ```{r fg6_1, echo=T,eval=T,fig.height=5,fig.width=10} ggplot(ODD_graphique1) + geom_point(aes(x = log(Gross_Domestic_Product_GDP), - y = log(Maternal_mortality_ratio), - color = Continent)) + + y = log(Maternal_mortality_ratio), + color = Continent)) + labs(title = "Mortalité maternelle en fonction du PIB par habitant", - subtitle = "En 2015", - x = "PIB", - y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", - color = "Les continents", - caption = "Source : ODD / ONU") + subtitle = "En 2015", + x = "PIB", + y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", + color = "Les continents", + caption = "Source : ODD / ONU") ``` À noter qu'il existe plusieurs autres façons de spécifier ces éléments par des couches spécifiques: `ggtitle`, `xlab`, `ylab`,... @@ -27,19 +27,19 @@ Les guides peuvent être spécifiés dans chaque scale_* ou dans une instruction ```{r fg6_2, echo=T,eval=T,fig.height=5,fig.width=10} ggplot(ODD_graphique1) + geom_point(aes(x = log(Gross_Domestic_Product_GDP), - y = log(Maternal_mortality_ratio), - color = Continent)) + + y = log(Maternal_mortality_ratio), + color = Continent)) + labs(title = "Mortalité maternelle en fonction du PIB par habitant", - subtitle = "En 2015", - x = "PIB", - y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", - caption = "Source : ODD / ONU") + + subtitle = "En 2015", + x = "PIB", + y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", + caption = "Source : ODD / ONU") + guides(color = guide_legend(direction = "horizontal", - order = 1, - title.position = "top", - title.hjust = 0.5, - nrow = 1, - label.position = "bottom")) + + order = 1, + title.position = "top", + title.hjust = 0.5, + nrow = 1, + label.position = "bottom")) + theme(legend.position = "bottom") ``` @@ -51,26 +51,26 @@ Il est aussi possible de rajouter des annotations de type texte ou autre, par ex ggplot(ODD_graphique1) + geom_point(aes(x = log(Gross_Domestic_Product_GDP), - y = log(Maternal_mortality_ratio), - color = Continent)) + + y = log(Maternal_mortality_ratio), + color = Continent)) + labs(title = "Mortalité maternelle en fonction du PIB par habitant", - subtitle = "En 2015", - x = "PIB", - y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", - caption = "Source : ODD / ONU") + + subtitle = "En 2015", + x = "PIB", + y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", + caption = "Source : ODD / ONU") + annotate("label", - x = 11, - y = 6.5, - size = 3, - label = "882 décès \npour 100 000 naissances \nen République centrafricaine", - color = "white", - fill = "red") + + x = 11, + y = 6.5, + size = 3, + label = "882 décès \npour 100 000 naissances \nen République centrafricaine", + color = "white", + fill = "red") + annotate("curve", - xend = log(333.1885), yend = log(882), - x = 10.2, y = 6.5, - curvature = -0.1, - color = "red", - arrow = arrow(length = unit(2, "mm")) + xend = log(333.1885), yend = log(882), + x = 10.2, y = 6.5, + curvature = -0.1, + color = "red", + arrow = arrow(length = unit(2, "mm")) ) + theme(legend.position = "bottom") ``` diff --git a/07-les-themes.Rmd b/07-les-themes.Rmd index 8713371..77770b0 100644 --- a/07-les-themes.Rmd +++ b/07-les-themes.Rmd @@ -83,7 +83,7 @@ panel.background, panel.border, panel.grid.major, panel.grid.minor,... ## Quelques exemples -```{r fg7_0, echo=T,eval=T,fig.height=5,fig.width=10} +```{r fg7_0, echo=TRUE,eval=TRUE,fig.height=5,fig.width=10} gg <- ggplot(ODD_graphique1) + geom_point(aes(x = log(Gross_Domestic_Product_GDP), y = log(Maternal_mortality_ratio), @@ -104,14 +104,14 @@ gg + - Changer l'apparence du quadrillage ***panel_background*** -```{r fg7_2, echo=T,eval=T,fig.height=5,fig.width=10} +```{r fg7_2, echo=TRUE,eval=TRUE,fig.height=5,fig.width=10} gg + theme(panel.grid.major = element_line(colour = "gray", size = 0.5, linetype = "dashed")) ``` - Changer l'apparence des étiquettes des axes ***axis_xxx()*** -```{r fg7_3, echo=T,eval=T,fig.height=5,fig.width=10} +```{r fg7_3, echo=TRUE,eval=TRUE,fig.height=5,fig.width=10} gg + theme(axis.text.x = element_text(colour = "blue", angle = 45), axis.title = element_text(face = "bold", colour = "orange")) @@ -120,7 +120,7 @@ gg + Certains changements de paramètres ne nécessitent pas l'utilisation de fonction ***element_()*** . Par exemple, pour changer la position de la légende ***legend.xxx()*** -```{r fg7_4, echo=T,eval=T,fig.height=5,fig.width=10} +```{r fg7_4, echo=TRUE,eval=TRUE,fig.height=5,fig.width=10} gg + theme(legend.position = "left", legend.title = element_blank()) ``` @@ -129,7 +129,7 @@ gg + La fonction `theme_set()` vous permet de définir un thème par défaut pour l'ensemble de vos graphiques. -```{r fg7_5, echo=T,eval=T,fig.height=5,fig.width=10} +```{r fg7_5, echo=TRUE,eval=TRUE,fig.height=5,fig.width=10} theme_set(theme_dark()) # Le theme_dark() sera appliqué à tous les graphiques à partir de maintenant @@ -213,36 +213,12 @@ ggplot(ODD_graphique1) + NB: Pour les cartes, [theme_gouv_map()](https://spyrales.github.io/gouvdown/reference/theme_gouv_map.html) sera privilégié. +Le thème ne joue pas sur la palette de couleurs employée par défaut, RDV au chapitre suivant. + ## Exercice 2 -> A partir des données de la table graphique 1 ('ODD_graphique1'), reprendre le nuage de point obtenu à partir des données ODD : taux de mortalité maternelle (Maternal_mortality_ratio) en fonction du produit intérieur brut (Gross_Domestic_Product_GDP) (Chapitre 7.1) -> -> En modifier le thème: -> -> - Insérer un titre de couleur, en gras, centré par rapport au graphe. -> - Indiquer la source (ODD) et modifier sa taille -> - Changer les titres des axes et leurs tailles. -> - modifier la couleur de fond du graphe -> - modifier le type de gadrillage (pointillés) +```{r mod5_exo2, child=charge_exo('m5', 'exo2.rmd'), echo=FALSE} -Le résultat attendu +``` -```{r fg7_7, eval=T,echo=F,message=F,warning=F} -ggplot(ODD_graphique1) + - geom_point(aes(x = log(Gross_Domestic_Product_GDP), - y = log(Maternal_mortality_ratio), - color = Continent)) + - labs(title = "Croisement du PIB avec le taux de mortalité maternelle", y = "Taux de mortalité maternelle", x = "Produit Intérieur Brut", caption = "Source: ODD") + - theme(legend.position = "bottom", - plot.title = element_text(size = 15, - face = "bold", - color = "blue", - hjust = 0.5), - plot.caption = element_text(size = 15), - axis.title.x = element_text(size = 15), - axis.title.y = element_text(size = 15), - panel.background = element_rect(fill = "lightblue", colour = "lightblue", size = 0.5), - panel.grid.major = element_line(size = 0.5, linetype = "dotted"), - panel.grid.minor = element_line(size = 0.5, linetype = "dotted")) -``` diff --git a/08-les-scales.Rmd b/08-les-scales.Rmd index bef8645..b88f024 100644 --- a/08-les-scales.Rmd +++ b/08-les-scales.Rmd @@ -107,6 +107,16 @@ gg + scale_color_gouv_discrete(name = "", palette = "pal_gouv_qual1") + theme_gouv() ``` + + +On peut récupérer le code hex d'une couleur des palettes de la marque Etat avec la fonction `gouv_colors()`. +```{r gouv_colors} +gouv_colors("r4") +``` + +![](images/palette.PNG){#id .class width=500} + + ## Formatage spécifique - Transformation en pourcentage; @@ -144,31 +154,6 @@ scale_y_continuous(expand = c(0, 0)) ## Exercice 3 -> En réutilisant le graphe obtenu à l'exercice 1 (table rpls_aggrege_large), y rajouter: -> -> - une palette brewer pour la couleur; -> -> - la légende en bas; -> -> - des libellés (axes et légende) parlant et un titre. - -Le résultat attendu - -```{r fg8_5,eval=T,message=F,echo=F,warning=F} -ggplot(data = rpls_aggrege_large %>% - filter(TypeZone == "Epci")) + - geom_point(aes(x = Parc_de_moins_de_5_ans_pourcent, - y = DPE_GES_classe_ABC_pourcent, - color = epci_2017_52), - size = .7 - ) + - scale_color_brewer(type = "qual", palette = "Paired", - labels = c("Autres Epci", "Epci de la région Pays de la Loire")) + - scale_x_continuous(limits = c(0, 40)) + - scale_y_continuous(limits = c(0, 80)) + - theme(legend.position = "bottom") + - labs(title = "Répartition des Epci en fonction \nde la part des logements ayant une étiquette A,B,C et de la part du parc récent", - x = "Part du parc de moins de 5 ans", - y = "Part des logements ayant une étiquette A,B,C", - color = "") -``` +```{r mod5_exo3, child=charge_exo('m5', 'exo3.rmd'), echo=FALSE} + +``` \ No newline at end of file diff --git a/10-les-facettes.Rmd b/10-les-facettes.Rmd index e331ea9..420e76c 100644 --- a/10-les-facettes.Rmd +++ b/10-les-facettes.Rmd @@ -28,17 +28,20 @@ ODD_indicateur311 %>% Cet exemple "scinde" notre table en fonction d'une seule variable, mais on peut le faire sur plusieurs variables également. -On peut choisir avec facet_wrap : -- le nombre de colonnes ou de lignes sur lesquels on veut voir s'afficher le graphique ; +On peut choisir avec `facet_wrap()` : + +- le nombre de colonnes ou de lignes sur lesquels on veut voir s'afficher le graphique ; + - si on veut fixer l'échelle de l'un ou l'autre des axes ou les deux. + ```{r f7_2, echo=T,eval=T,fig.height=5,fig.width=12} ODD_indicateur311 %>% filter(Type_Zone != "Pays", - Age_group == "All age ranges or no breakdown by age", - Sex == "Both sexes or no breakdown by sex", - Location == "Total (national level)", - is.na(Value_type) + Age_group == "All age ranges or no breakdown by age", + Sex == "Both sexes or no breakdown by sex", + Location == "Total (national level)", + is.na(Value_type) ) %>% filter(Year %in% c(2000, 2005, 2010, 2015)) %>% ggplot() + @@ -47,10 +50,10 @@ ODD_indicateur311 %>% scale_fill_ipsum() + coord_flip() + labs(title = "Mortalité maternelle sur quelques zones du globe", - subtitle = "Années 2000 à 2015", - y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", - x = "Zone", - fill = "Zone" + subtitle = "Années 2000 à 2015", + y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", + x = "Zone", + fill = "Zone" ) + theme(legend.position = "none") + facet_wrap(facets = "Year", ncol = 4) @@ -58,17 +61,11 @@ ODD_indicateur311 %>% ## Exercice 4 -> A partir de la table rpls_aggrege, réaliser une facette sur un diagramme barre avec : -> -> * en variable discrète les régions -> * en variables continues les indicateurs suivants : -> - % de logements de 3 et 4 pièces -> - % DPE énergie A,B,C -> - % DPE GES A,B,C -> - % de parc de moins de 5 ans -> * une façon d'identifier la région Pays de la Loire (code region '52') - -Pour avoir la liste des modalités dune variable : +```{r mod5_exo4, child=charge_exo('m5', 'exo4.rmd'), echo=FALSE} + +``` + +Astuces : pour avoir la liste des modalités dune variable : - Variables caractères ou factorielles : @@ -82,31 +79,4 @@ unique(rpls_aggrege$Indicateur) levels(rpls_aggrege$Indicateur) ``` -Résultat attendu - - -```{r f7_5,eval=T,fig.height=8,fig.width=12,message=F,warning=F,echo=FALSE} -rpls_aggrege %>% - filter(TypeZone == "Régions", - Indicateur %in% c("3 et 4 pièces_pourcent", - "DPE GES classe ABC_pourcent", - "DPE énergie classe ABC_pourcent", - "Parc de moins de 5 ans_pourcent")) %>% - mutate(Indicateur = fct_recode(Indicateur, - `Logements sociaux de 3 et 4 pièces` = "3 et 4 pièces_pourcent", - `Logements sociaux avec DPE énergie de classe A,B,C` = "DPE énergie classe ABC_pourcent", - `Logements sociaux avec DPE GES de classe A,B,C` = "DPE GES classe ABC_pourcent", - `Logements sociaux de moins de 5 ans` = "Parc de moins de 5 ans_pourcent"), - r52 = ifelse(Reg_2017 == "52", 1, 0)) %>% - ggplot() + - # On utilise l'indicatrice de la région Pays de la Loire pour mapper la transparence - geom_col(aes(x = nReg_2017, y = Valeur, fill = Indicateur, alpha = r52)) + - coord_flip() + - theme_minimal() + - scale_fill_ipsum() + - # On défini les valeurs maximum et minimum de transparence que l'on veut voir - scale_alpha_continuous(range = c(0.65, 1)) + - facet_wrap("Indicateur") + - theme(legend.position = "none") + - labs(title = "mon premier facet", y = "En % du parc social", x = "") -``` + diff --git a/11-sauvegarder-un-graphique.Rmd b/11-sauvegarder-un-graphique.Rmd index faa3b55..7585deb 100644 --- a/11-sauvegarder-un-graphique.Rmd +++ b/11-sauvegarder-un-graphique.Rmd @@ -1,14 +1,15 @@ # Exporter un graphique -La fonction `ggsave()` de ggplot2 permet d'exporter des graphiques au format image. Les formats suivants sont supportés : eps, ps, tex (pictex), pdf, jpeg, tiff, png, bmp, svg et wmf. +La fonction `ggsave()` de ggplot2 permet d'exporter des graphiques au format image. +Les formats suivants sont supportés : eps, ps, tex (pictex), pdf, jpeg, tiff, png, bmp, svg et wmf. -```{r exp_1, echo=T,eval=F,fig.height=5,fig.width=12} +```{r exp_1, echo=TRUE, eval=FALSE, fig.height=5, fig.width=12} p <- ODD_indicateur311 %>% filter(Type_Zone != "Pays", - Age_group == "All age ranges or no breakdown by age", - Sex == "Both sexes or no breakdown by sex", - Location == "Total (national level)", - is.na(Value_type) + Age_group == "All age ranges or no breakdown by age", + Sex == "Both sexes or no breakdown by sex", + Location == "Total (national level)", + is.na(Value_type) ) %>% filter(Year %in% c(2000, 2005, 2010, 2015)) %>% ggplot() + @@ -17,10 +18,10 @@ p <- ODD_indicateur311 %>% scale_fill_ipsum() + coord_flip() + labs(title = "Mortalité maternelle sur quelques zones du globe", - subtitle = "En 2015", - y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", - x = "Zone", - fill = "Zone" + subtitle = "En 2015", + y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", + x = "Zone", + fill = "Zone" ) + theme(legend.position = "none") + facet_wrap("Year", ncol = 4) diff --git "a/12-cr\303\251er-des-cartes-avec-ggplot2.Rmd" "b/12-cr\303\251er-des-cartes-avec-ggplot2.Rmd" index fae6270..27d2fed 100644 --- "a/12-cr\303\251er-des-cartes-avec-ggplot2.Rmd" +++ "b/12-cr\303\251er-des-cartes-avec-ggplot2.Rmd" @@ -8,22 +8,27 @@ Une fonction géométrique de ggplot2 permet l'utilisation de données géomatiq L'exemple suivant est une carte choroplèthe. -```{r cart_1, echo=T,eval=T,fig.height=5,fig.width=12, cache=TRUE} +```{r cart_1, echo=TRUE, eval=TRUE, fig.height=5, fig.width=12, cache=TRUE} + data("World") tt <- World %>% rename(Country_or_Area_Code = iso_a3) %>% - inner_join(ODD_indicateur311 %>% - filter(Age_group == "All age ranges or no breakdown by age", - Sex == "Both sexes or no breakdown by sex", - Type_Zone == "Pays", - is.na(Value_type)) %>% - group_by(Country_or_Area_Code) %>% - filter(!is.na(Value)) %>% - filter(Year == max(Year))) + inner_join( + ODD_indicateur311 %>% + filter(Age_group == "All age ranges or no breakdown by age", + Sex == "Both sexes or no breakdown by sex", + Type_Zone == "Pays", + is.na(Value_type)) %>% + group_by(Country_or_Area_Code) %>% + filter(!is.na(Value)) %>% + filter(Year == max(Year)), + by = "Country_or_Area_Code") ggplot(data = tt) + - geom_sf(aes(fill = Value)) + geom_sf(aes(fill = Value)) + + theme_gouv_map() + + scale_fill_gouv_continuous(palette = "pal_gouv_h", reverse = TRUE) ``` ## Les cartes à ronds proportionnels @@ -31,7 +36,7 @@ ggplot(data = tt) + La fonction ***stat_sf_coordinates()*** permet d'extraire les coordonnées d'un objet 'sf'. Ainsi un rond proportionnel peut être attribué à un polygone. -```{r cart_3, echo=T,eval=T,fig.height=5,fig.width=12, cache=TRUE} +```{r cart_3, echo=TRUE, eval=TRUE, fig.height=5, fig.width=12, cache=TRUE} data("World") tt <- World %>% @@ -46,10 +51,10 @@ tt <- World %>% filter(Year == max(Year))) ggplot(data = tt) + - geom_sf(fill = "grey97") + + geom_sf(fill = gouv_colors("r5")) + + theme_gouv_map() + stat_sf_coordinates(aes(size = Value, fill = Value), color = "black", shape = 21) + - scale_fill_gradient2(name = "Valeur", - low = "darkblue", mid = "white", high = "darkred") + + scale_fill_gradient(name = "Valeur", low = "white", high = gouv_colors("i1")) + scale_size_area(name = "Valeur", max_size = 10) ``` @@ -158,20 +163,9 @@ ggplot(data = tt %>% filter(continent == "Africa")) + ## Exercice 5 -> Produire une carte du Loiret à l'EPCI du taux de logements collectifs dans le parc locatif social. - -Résultat attendu +```{r mod5_exo5, child=charge_exo('m5', 'exo5.rmd'), echo=FALSE} -```{r cart_7,eval=T,echo=F,message=F,warning=F} -tt <- Carte_EPCI_France %>% - filter(CODE_DEPT == "45") %>% - left_join(rpls_aggrege) %>% - filter(Indicateur == "Logements collectifs_pourcent") -ggplot(data = tt) + - geom_sf(aes(geometry = geometry, fill = Valeur)) + - labs(title = "Taux de logements collectifs par EPCI", subtitle = "Département du Loiret") + - theme( - axis.text.x = element_blank(), - axis.text.y = element_blank(), - axis.ticks = element_blank()) ``` + + +Note : A partir du fond de carte `Carte_EPCI_FRANCE`. \ No newline at end of file diff --git "a/12b-graphiques-anim\303\251s.Rmd" "b/12b-graphiques-anim\303\251s.Rmd" index 8777e74..a4f6484 100644 --- "a/12b-graphiques-anim\303\251s.Rmd" +++ "b/12b-graphiques-anim\303\251s.Rmd" @@ -13,32 +13,32 @@ Pour cela, nous partons des même données mais définies pour l'ensemble des an ```{r gganim_1} ggplot(data = ODD_graphique_anime) + geom_point(aes(x = log(Gross_Domestic_Product_GDP), - y = log(Maternal_mortality_ratio), - color = Continent)) + + y = log(Maternal_mortality_ratio), + color = Continent)) + labs(title = "Mortalité maternelle en fonction du PIB par habitant", - subtitle = "En 2015", - x = "PIB", - y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", - caption = "Source : ODD / ONU\n échelle logarithmique") + subtitle = "En 2015", + x = "PIB", + y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", + caption = "Source : ODD / ONU\n échelle logarithmique") ``` -Le graphique précédent est bien sûr illisible, un même pays voit ces données affichées pour toutes les années. +Le graphique précédent est bien sûr illisible, un même pays voit ses données affichées pour toutes les années. Nous allons utiliser la fonction ***transition_states()*** du package `gganimate` pour lui définir l'année comme la frame de notre graphique animé. ```{r gganim_2,,warning = FALSE,message = FALSE,error=FALSE, cache=TRUE} anim <- ggplot(data = ODD_graphique_anime) + geom_point(aes(x = log(Gross_Domestic_Product_GDP), - y = log(Maternal_mortality_ratio), - color = Continent)) + + y = log(Maternal_mortality_ratio), + color = Continent)) + labs(title = "Mortalité maternelle en fonction du PIB par habitant", - subtitle = "En {closest_state}", - x = "PIB", - y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", - caption = "Source : ODD / ONU\n échelle logarithmique") + + subtitle = "En {closest_state}", + x = "PIB", + y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", + caption = "Source : ODD / ONU\n échelle logarithmique") + transition_states(states = Year, - transition_length = 1, - state_length = 2) + transition_length = 1, + state_length = 2) anim ``` @@ -62,17 +62,17 @@ On peut utiliser gganimate avec des facettes. ```{r gganim_3,warning = FALSE,message = FALSE,error=FALSE,cache=TRUE} anim_facet <- ggplot(data = ODD_graphique_anime) + geom_point(aes(x = log(Gross_Domestic_Product_GDP), - y = log(Maternal_mortality_ratio), - color = Continent)) + + y = log(Maternal_mortality_ratio), + color = Continent)) + labs(title = "Mortalité maternelle en fonction du PIB par habitant", - subtitle = "En {closest_state}", - x = "PIB", - y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", - caption = "Source : ODD / ONU\n échelle logarithmique") + + subtitle = "En {closest_state}", + x = "PIB", + y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", + caption = "Source : ODD / ONU\n échelle logarithmique") + facet_wrap("Continent") + transition_states(states = Year, - transition_length = 1, - state_length = 2) + transition_length = 1, + state_length = 2) anim_facet ``` @@ -88,9 +88,9 @@ Ici par exemple, nous paramétrons le rendu pour supprimer la boucle d'animation ```{r gganim_4,warning = FALSE,message = FALSE,error=FALSE} animate(anim, renderer = gifski_renderer(file = tempfile(fileext = ".gif"), - loop = FALSE, - width = NULL, - height = NULL) + loop = FALSE, + width = NULL, + height = NULL) ) ``` @@ -105,48 +105,7 @@ anim_save("figures/ma_super_animation.gif") ## Exercice 6 -A partir du fichier `rpls_aggrege_large.RData`, réaliser un graphique en barre représentant la répartition des DPE par classe (en %). -Le graphique sera animé par département, uniquement pour ceux de la région Centre-Val de Loire. - -Le résultat attendu : - -```{r gganim_6, eval=T,message=F,warning=F,echo=FALSE, cache=TRUE} -library(dplyr) -library(tidyr) -library(forcats) -library(ggplot2) -library(gganimate) -library(stringr) - -rpls <- rpls_aggrege_large %>% - # Filtre sur la zone de travail souhaitée - filter(TypeZone == "Départements" & nReg_2017 == "Centre-Val de Loire") %>% - # Suppression des levels non présents dans la table, - # ce qui évite de générer des graphes vident pour les départements hors Centre-Val de Loire - mutate(nDep_2017 = fct_drop(nDep_2017)) %>% - # Selection des variables nécessaires - select(nDep_2017, DPE_energie_classe_ABC_pourcent, DPE_energie_classe_D_pourcent, - DPE_energie_classe_EFG_pourcent, DPE_energie_classe_NA_pourcent) %>% - # Passage de la table au format long (cf module 2, chapitre 7) - pivot_longer(-c(nDep_2017), names_to = "variable", values_to = "valeur") %>% - # Retravail des intitulés pour ne conserver que la classe d'energie ABC/D/EGF/NA - mutate(variable = str_remove(pattern = "DPE_energie_classe_", variable), - variable = str_remove(pattern = "_pourcent", variable)) - -ggplot(data = rpls, aes(x = variable, y = valeur, fill = variable)) + - geom_col() + - # definition des couleurs - scale_fill_manual(values = c("#66CD00", "#FFFF00", "#FF7F00", "#A8A8A8")) + - # suppression de la legende - theme(legend.position = "none") + - # habillage: titre, libellé des axes, Source - labs(title = "Les DPE dans le parc locatif social", - subtitle = "En {closest_state}", - x = "Classe d'énergie", - y = "%", - caption = "Source : Répertoire Locatif Social") + - # création de l'animation - transition_states(states = nDep_2017, - transition_length = 1, - state_length = 5) +```{r mod5_exo6, child=charge_exo('m5', 'exo6.rmd'), echo=FALSE} + ``` + diff --git "a/13-cr\303\251er-des-graphiques-et-cartes-pour-le-web.Rmd" "b/13-cr\303\251er-des-graphiques-et-cartes-pour-le-web.Rmd" index 94f6d99..a02e231 100644 --- "a/13-cr\303\251er-des-graphiques-et-cartes-pour-le-web.Rmd" +++ "b/13-cr\303\251er-des-graphiques-et-cartes-pour-le-web.Rmd" @@ -8,7 +8,7 @@ Ce package rajoute des fonctionnalités à `ggplot2` comme par exemple [geom_bar_interactive()](https://davidgohel.github.io/ggiraph/reference/geom_bar_interactive.html),`geom_line_interactive()`, `geom_point_interactive()`, ... -Il existe 3 types d'ajout: +Il existe 3 types d'ajout : - `tooltip`: l'information à afficher dans les infobulles au survol de la souris - `data_id`: l'identifiant à associer à l'élément (utilisé pour les actions de survol et de clic) @@ -25,27 +25,27 @@ Voici un exemple de diagramme barre sur les données de mortalités. gg <- ODD_indicateur311 %>% filter(Type_Zone != "Pays", - Age_group == "All age ranges or no breakdown by age", - Sex == "Both sexes or no breakdown by sex", - Location == "Total (national level)", - is.na(Value_type) + Age_group == "All age ranges or no breakdown by age", + Sex == "Both sexes or no breakdown by sex", + Location == "Total (national level)", + is.na(Value_type) ) %>% filter(Year %in% c(2015)) %>% ggplot() + geom_col_interactive(aes(x = Country_or_Area_Name, - y = Value, - fill = Country_or_Area_Name, - tooltip = paste(Value, "décès pour 100 000 naissances"))) + + y = Value, + fill = Country_or_Area_Name, + tooltip = paste(Value, "décès pour 100 000 naissances"))) + theme(legend.position = "none", - title = element_text(size = 8), - axis.text = element_text(size = 7)) + + title = element_text(size = 8), + axis.text = element_text(size = 7)) + scale_fill_ipsum() + coord_flip() + labs(title = "Mortalité maternelle sur quelques zones du globe", - subtitle = "En 2015", - y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", - x = "Zone", - fill = "Zone" + subtitle = "En 2015", + y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", + x = "Zone", + fill = "Zone" ) girafe(ggobj = gg, height_svg = 3) @@ -62,18 +62,18 @@ gg <- ggplot(data = ODD_graphique2) + geom_line(aes(x = Year, y = Value)) + geom_point(aes(x = Year, y = Value)) + geom_point_interactive(aes(x = Year, y = Value, - tooltip = paste(Year, "\n", Value, "décès pour 100 000 naissances"))) + + tooltip = paste(Year, "\n", Value, "décès pour 100 000 naissances"))) + labs(title = "Mortalité maternelle sur quelques zones du globe", - subtitle = "En 2015", - y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", - x = "Zone", - fill = "Zone" + subtitle = "En 2015", + y = "Taux de mortalité de la mère \n(pour 100 000 naissances)", + x = "Zone", + fill = "Zone" ) + theme_minimal() girafe(ggobj = gg, height_svg = 3, - options = list( - opts_tooltip(css = "background-color:gray;font-style:italic;border-radius:5px;padding:5px;"))) + options = list( + opts_tooltip(css = "background-color:gray;font-style:italic;border-radius:5px;padding:5px;"))) ``` Les éléments associés à `data_id` sont animés au survol de la souris. Ces animations sont configurées par les options suivantes: @@ -252,30 +252,8 @@ saveWidget(widget = carte_rond_proportionnel, file = "Taux de décès des mères ``` - ## Exercice 7 +```{r mod5_exo7, child=charge_exo('m5', 'exo7.rmd'), echo=FALSE} -Reprendre le nuage de point obtenu à partir des données ODD : taux de mortalité maternelle (Maternal_mortality_ratio) en fonction du produit intérieur brut (Gross_Domestic_Product_GDP) (Chapitre 9) - -Obtenir ce graphique pour le web avec des infos bulles regroupant le nom du continent, de la zone, le PIB et le taux de mortalité maternelle. -Paramétrer la surbrillance du continent au survol d'élément. - -Le résultat attendu : - -```{r eval=T,message=F,warning=F,echo=FALSE} - -gg <- ggplot(ODD_graphique1) + - geom_point_interactive(aes(x = log(Gross_Domestic_Product_GDP), - y = log(Maternal_mortality_ratio), - color = Continent, - data_id = Continent, - tooltip = paste(Continent, "\n", Parent_Zone_libelle, - "\nPIB de", round(Gross_Domestic_Product_GDP, 1), - "\nun taux de mortalié maternelle de", Maternal_mortality_ratio, - "(pour 100 000 naissances)"))) + - scale_color_brewer(type = "qual") - -girafe(ggobj = gg, height_svg = 3, options = list(opts_hover(css = "fill:darkblue;"))) -``` - +``` \ No newline at end of file diff --git "a/14-cr\303\251er-des-tableaux-avec-kable.Rmd" "b/14-cr\303\251er-des-tableaux-avec-kable.Rmd" index 4fcb00e..232a776 100644 --- "a/14-cr\303\251er-des-tableaux-avec-kable.Rmd" +++ "b/14-cr\303\251er-des-tableaux-avec-kable.Rmd" @@ -40,7 +40,7 @@ Description des fonctions utilisées : ## Sauvegarde Le tableau ainsi produit peut être sauvegardé sous plusieurs formats (html, png, pdf, etc..) grâce à la fonction ***save_kable***. -Cette fonction nécessite le chargement du package ***magick*** +Cette fonction nécessite le chargement du package ***kableExtra***. ```{r kabble_2} ODD_indicateur311 %>% @@ -64,18 +64,6 @@ ODD_indicateur311 %>% ## Exercice 8 -Produire un tableau du nombre de logements collectifs et individuels (RPLS) par départements en région Centre-Val de Loire. +```{r mod5_exo8, child=charge_exo('m5', 'exo8.rmd'), echo=FALSE} -Le résultat attendu : - -```{r kabble_3, eval=T,message=F,warning=F,echo=FALSE} -rpls_DEP_R24 <- rpls_aggrege_large %>% - filter(TypeZone %in% c("Départements", "Régions"), nReg_2017 == "Centre-Val de Loire") %>% - arrange(TypeZone, Zone) %>% - select(Zone, Logements_collectifs, Logements_individuels) %>% - setNames(c("Zone", "Nombre de logements collectifs", "Nombre de logements individuels")) %>% - kable("html", caption = "Chiffres clés RPLS") %>% - kable_styling(bootstrap_options = c("striped", "hover")) %>% - row_spec(7, bold = T, color = "white", background = "grey") -rpls_DEP_R24 ``` diff --git a/16-exercices.Rmd b/16-exercices.Rmd index a46a5e5..4b48143 100644 --- a/16-exercices.Rmd +++ b/16-exercices.Rmd @@ -2,251 +2,66 @@ ## Exercice 1 -> A partir des données de la table rpls_aggrege_large (dans extdata/rpls_aggrege_large.RData), -> -> créer un nuage de point (un point par EPCI, filtre sur la variable TypeZone) entre : -> -> - le % de parc social de moins de 5 ans ('Parc_de_moins_de_5_ans_pourcent'); -> -> - et le pourcentage de logement avec un DPE ges de classe A, B ou C ('DPE_GES_classe_ABC_pourcent'); -> -> - et une couleur différente pour distinguer les epci de la région PDL (booléen 'epci_2017_52'). - -```{r exo_1, eval=T, message=F,warning=F} -ggplot(data = rpls_aggrege_large %>% - filter(TypeZone=="Epci")) + - geom_point(aes(x=Parc_de_moins_de_5_ans_pourcent, - y=DPE_GES_classe_ABC_pourcent, - color=epci_2017_52), - alpha=.5, - size=.5 ) +```{r mod5_exo1_cor, child=charge_exo('m5', 'exo1.rmd'), echo=TRUE} + ``` ## Exercice 2 -> Reprendre le nuage de points obtenu à partir des données ODD : taux de mortalité maternelle (Maternal_mortality_ratio) en fonction du produit intérieur brut (Gross_Domestic_Product_GDP) (Chapitre 7.1) -> -> En modifier le thème : -> -> - Insérer un titre, de couleur, en gras, centré par rapport au graphe -> - Indiquer la source (ODD) et modifier sa taille -> - Changer les titres des axes et leurs tailles -> - Modifier la couleur de fond du graphe -> - Modifier le type de quadrillage (pointillés) - -```{r exo_2, eval=T,message=F,warning=F} -ggplot(ODD_graphique1) + - geom_point(aes(x=log(Gross_Domestic_Product_GDP), - y=log(Maternal_mortality_ratio), - color=Continent))+ - labs(title="Croisement du PIB avec le taux de mortalité maternelle", - y="Taux de mortalité maternelle", x="Produit Intérieur Brut", caption="Source: ODD")+ - theme(plot.title=element_text(size=15, - face="bold", - color="blue", - hjust=0.5), - plot.caption=element_text(size=15), - axis.title.x=element_text(size=15), - axis.title.y=element_text(size=15), - panel.background = element_rect(fill = "lightblue",colour = "lightblue",size = 0.5), - panel.grid.major = element_line( size=0.5,linetype = "dotted"), - panel.grid.minor = element_line( size=0.5,linetype = "dotted")) +```{r mod5_exo2_cor, child=charge_exo('m5', 'exo2.rmd'), echo=TRUE} + ``` ## Exercice 3 -> En réutilisant le graphe obtenu à l'exercice 1, y rajouter: -> -> - une palette brewer pour la couleur ; -> -> - la légende en bas ; -> -> - des libellés (axes et légende) parlant et un titre. - -```{r exo_3, eval=T,message=F,warning=F} -ggplot(data = rpls_aggrege_large %>% - filter(TypeZone=="Epci")) + - geom_point(aes(x=Parc_de_moins_de_5_ans_pourcent, - y=DPE_GES_classe_ABC_pourcent, - color=epci_2017_52), - size=.7 - )+ - scale_color_brewer(type="qual", palette="Paired", - labels=c("Autres Epci","Epci de la région Pays de la Loire"))+ - scale_x_continuous(limits = c(0,40))+ - scale_y_continuous(limits = c(0,80))+ - theme(legend.position = "bottom")+ - labs(title="Répartition des Epci en fonction \nde la part des logements ayant une étiquette A,B,C et de la part du parc récent", - x="Part du parc de moins de 5 ans", - y="Part des logements ayant une étiquette A,B,C", - color="") +```{r mod5_exo3_cor, child=charge_exo('m5', 'exo3.rmd'), echo=TRUE} + ``` ## Exercice 4 -> A partir de la table rpls_aggrege, réaliser une facette sur un diagramme barre avec : -> -> * en variable discrète les régions -> * en variables continues les indicateurs suivants : -> - % de logements de 3 et 4 pièces -> - % DPE énergie A,B,C -> - % DPE GES A,B,C -> - % de parc de moins de 5 ans -> * une façon d'identifier la région Pays de la Loire (code region '52') +```{r mod5_exo4_cor, child=charge_exo('m5', 'exo4.rmd'), echo=TRUE} + +``` -Pour avoir la liste des modalités dune variable : +Astuces, pour avoir la liste des modalités dune variable : -Variables caractères ou factorielles : +- variables caractères ou factorielles : -```{r exo_4, eval=F,message=F,warning=F} +```{r, eval=FALSE,message=FALSE,warning=FALSE} unique(rpls_aggrege$Indicateur) ``` -Variables factorielles : +- variables factorielles : -```{r exo_5, eval=F,message=F,warning=F} +```{r, eval=FALSE,message=FALSE,warning=FALSE} levels(rpls_aggrege$Indicateur) ``` -```{r exo_6, eval=T,fig.height=8,fig.width=12,message=F,warning=F, cache=TRUE} -gg <- rpls_aggrege %>% - filter(TypeZone=="Régions", - Indicateur %in% c("3 et 4 pièces_pourcent", - "DPE GES classe ABC_pourcent", - "DPE énergie classe ABC_pourcent", - "Parc de moins de 5 ans_pourcent")) %>% - mutate(Indicateur=fct_recode(Indicateur, - `Logements de 3 et 4 pièces`="3 et 4 pièces_pourcent", - `Logements avec DPE énergie de classe A,B,C`="DPE énergie classe ABC_pourcent", - `Logements avec DPE GES de classe A,B,C`="DPE GES classe ABC_pourcent", - `Logements social de moins de 5 ans`="Parc de moins de 5 ans_pourcent"), - r52=ifelse(Reg_2017=="52", 1, 0.65)) %>% - ggplot()+ - #On utilise l'indicatrice de la région Pays de la Loire pour mapper la transparence - geom_col(aes(x=nReg_2017, y=Valeur, fill=Indicateur, alpha=r52))+ - coord_flip()+ - theme_minimal()+ - scale_fill_ipsum() + - facet_wrap("Indicateur")+ - theme(legend.position="none")+ - labs(title="mon premier facet", y="En % du parc social",x ="") - - - #solution 1 : On définit les valeurs maximum et minimum de transparence que l'on veut voir - gg + scale_alpha_continuous(range = c(.65, 1)) - - # solution 2 : On indique via la fonction scale_xx_identity que les valeurs peuvent être utilisées telles quelles - gg + scale_alpha_identity() - - # solution 3 : On indique via le paramètre rescaler de la fonction scale_alpha_continuous que les valeurs peuvent être utilisées telles quelles - gg + scale_alpha_continuous(rescaler = ~.x) - -``` ## Exercice 5 -> Produire une carte du Loiret à l'EPCI du taux de logements collectifs dans le parc locatif social. - -```{r exo_7, eval=T,message=F,warning=F, cache=TRUE} -tt <- Carte_EPCI_France %>% - filter(CODE_DEPT=="45") %>% - left_join(rpls_aggrege) %>% - filter(Indicateur=="Logements collectifs_pourcent") -ggplot(data=tt)+ - geom_sf(aes(geometry=geometry, fill=Valeur))+ - labs(title="Taux de logements collectifs par EPCI",subtitle="Département du Loiret")+ - theme( - axis.text.x = element_blank(), - axis.text.y = element_blank(), - axis.ticks = element_blank()) -``` +```{r mod5_exo5_cor, child=charge_exo('m5', 'exo5.rmd'), echo=TRUE} +``` ## Exercice 6 -A partir du fichier `rpls_aggrege_large.RData`, réaliser un graphique en barre représentant la répartition des DPE par classe (en %). -Le graphique sera animé par département, uniquement pour ceux de la région Centre-Val de Loire. - -```{r exo_8, eval=T,message=F,warning=F, cache=TRUE} -library(dplyr) -library(ggplot2) -library(gganimate) - -rpls <- rpls_aggrege_large %>% - #Filtre sur la zone de travail souhaitée - filter(TypeZone=="Départements" & nReg_2017=="Centre-Val de Loire")%>% - #Suppression des levels non présents dans la table, - #ce qui évite de générer des graphes vident pour les départements hors Centre-Val de Loire - mutate(nDep_2017=fct_drop(nDep_2017)) %>% - #Selection des variables nécessaires - select(nDep_2017,DPE_energie_classe_ABC_pourcent,DPE_energie_classe_D_pourcent, - DPE_energie_classe_EFG_pourcent,DPE_energie_classe_NA_pourcent) %>% - #Passage de la table au format long (cf module 2, chapitre 7) - pivot_longer(-c(nDep_2017),names_to ="variable",values_to ="valeur" ) %>% - #Retravail des intitulés pour ne conserver que la classe d'energie ABC/D/EGF/NA - mutate(variable=str_remove(pattern = "DPE_energie_classe_",variable), - variable=str_remove(pattern = "_pourcent",variable)) - -ggplot(data=rpls, aes(x=variable, y=valeur, fill=variable)) + - # geom_col() + - #definition des couleurs - scale_fill_manual(values=c("#66CD00", "#FFFF00", "#FF7F00", "#A8A8A8"))+ - #suppression de la legende - theme(legend.position="none")+ - #habillage: titre, libellé des axes, Source - labs(title="Les DPE dans le parc locatif social", - subtitle="En {closest_state}", - x="Classe d'énergie", - y="%", - caption="Source : Répertoire Locatif Social")+ - #création de l'animation - transition_states(states=nDep_2017, - transition_length = 1, - state_length = 5) +```{r mod5_exo6_cor, child=charge_exo('m5', 'exo6.rmd'), echo=TRUE} ``` -## Exercice 7 - -Reprendre le nuage de point obtenu à partir des données ODD :taux de mortalité maternelle (Maternal_mortality_ratio) en fonction du produit intérieur brut (Gross_Domestic_Product_GDP) (Chapitre 9) - -Obtenir ce graphique pour le web avec des infos bulles regroupant le nom du continent, de la zone, le PIB et le taux de mortalité maternelle. -Paramètrer la surbrillance du continent au survol d'élément. -Le résultat attendu : - -```{r exo_9, eval=T} +## Exercice 7 -gg <- ggplot(ODD_graphique1) + - geom_point_interactive(aes(x=log(Gross_Domestic_Product_GDP), - y=log(Maternal_mortality_ratio), - color=Continent, - data_id=Continent, - tooltip=paste(Continent,"\n",Parent_Zone_libelle, - "\nPIB de",round(Gross_Domestic_Product_GDP,1), - "\nun taux de mortalié maternelle de",Maternal_mortality_ratio, - "(pour 100 000 naissances)")))+ - scale_color_brewer(type="qual") +```{r mod5_exo7_cor, child=charge_exo('m5', 'exo7.rmd'), echo=TRUE} -girafe(ggobj=gg,height_svg = 3,options=list(opts_hover(css="fill:darkblue;"))) ``` - - ## Exercice 8 -Produire un tableau du nombre de logements collectifs et individuels (RPLS) par départements en région Centre-Val de Loire. - -```{r exo_10, eval=T} -rpls_DEP_R24 <- rpls_aggrege_large %>% - filter(TypeZone %in% c("Départements","Régions"),nReg_2017=="Centre-Val de Loire") %>% - arrange(TypeZone,Zone) %>% - select(Zone,Logements_collectifs,Logements_individuels)%>% - setNames(c("Zone","Nombre de logements collectifs","Nombre de logements individuels")) %>% - kable("html",caption="Chiffres clés RPLS") %>% - kable_styling(bootstrap_options = c("striped", "hover")) %>% - row_spec(7, bold = T, color = "white", background = "grey") -rpls_DEP_R24 -``` +```{r mod5_exo8_cor, child=charge_exo('m5', 'exo8.rmd'), echo=TRUE} + +``` \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index 5d5f883..4d1988a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,48 @@ -Package: Parcours-R +Package: parcours_r_module_datavisualisation Type: Book -Title: Formations à R +Title: Formations R du MTES - Module 5 Datavisualisation Version: 0.1.0 +Authors@R: c( + person("Juliette", "Engelaere-Lefebvre", , "juliette.engelaere@developpement-durable.gouv.fr", role = c("aut", "cre")), + person("Murielle", "Delmotte", , "murielle@thinkr.fr", role = "aut", comment = c(ORCID = "0000-0002-1339-2424")), + person("Mael", "Theuliere", , "mael.theuliere@gmail.com", role = "aut") + ) +Description: Valise pedagogique pour la formation a R au Ministere de la transition ecologique, 5e module sur la datavisualisation. +License: LICENCE OUVERTE/ OPEN LICENCE Version 2.0 URL: https://github.com/MTES-MCT/parcours_r_module_datavisualisation -Imports: rmarkdown, htmltools, tidyverse, cartography, sf, GGally, dplyr, plotly, bookdown, RcppRoll, DT, RPostgreSQL, rsdmx, XML, lsr, ggmosaic, visNetwork, FactoMineR, factoextra, ggExtra, kableExtra, hrbrthemes, tmap, highcharter, gganimate, svglite, cowplot, gifski, docopt, webshot, ggspatial -License: MIT -Description: Valise pédagogique pour la formation à R \ No newline at end of file +Imports: + apexcharter, + bookdown, + COGiter, + cowplot, + dplyr, + forcats, + gganimate, + ggiraph, + ggplot2, + ggspatial, + gifski, + glue, + gouvdown, + gouvdown.fonts, + highcharter, + hrbrthemes, + htmltools, + htmlwidgets, + kableExtra, + knitr, + leaflet, + purrr, + rmarkdown, + scales, + savoirfR, + sf, + webshot +Remotes: + MaelTheuliere/COGiter, + MTES-MCT/savoirfR, + spyrales/gouvdown, + spyrales/gouvdown.fonts, + git::https://gitlab-forge.din.developpement-durable.gouv.fr/dreal-pdl/csd/mapfactory.git@main + + diff --git a/Dockerfile b/Dockerfile index 390fc10..bcbc42c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,8 @@ -ARG R_VERSION=4.2.1 +ARG R_VERSION=4.2.2 FROM inseefrlab/onyxia-rstudio:r${R_VERSION} -ENV RENV_VERSION 0.16.0 RUN apt-get update && apt-get install -y cargo RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))" -RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')" -COPY renv.lock renv.lock -RUN R -e 'renv::restore()' +COPY DESCRIPTION DESCRIPTION +RUN R -e 'remotes::install_deps(dependencies = TRUE)' +RUN R -e 'webshot::install_phantomjs()' diff --git a/extdata/Carte_EPCI_France.RData b/extdata/Carte_EPCI_France.RData deleted file mode 100644 index ce4e08d..0000000 Binary files a/extdata/Carte_EPCI_France.RData and /dev/null differ diff --git a/extdata/ODD.RData b/extdata/ODD.RData deleted file mode 100644 index 3435ecc..0000000 Binary files a/extdata/ODD.RData and /dev/null differ diff --git a/extdata/rpls_aggrege.RData b/extdata/rpls_aggrege.RData deleted file mode 100644 index ad8782c..0000000 Binary files a/extdata/rpls_aggrege.RData and /dev/null differ diff --git a/extdata/rpls_aggrege_large.RData b/extdata/rpls_aggrege_large.RData deleted file mode 100644 index 3a80d30..0000000 Binary files a/extdata/rpls_aggrege_large.RData and /dev/null differ diff --git a/figures/ma_super_animation.gif b/figures/ma_super_animation.gif index dd7fbac..2f65d7b 100644 Binary files a/figures/ma_super_animation.gif and b/figures/ma_super_animation.gif differ diff --git a/images/cheat_sheet_ggplot2.png b/images/cheat_sheet_ggplot2.png new file mode 100644 index 0000000..b8af392 Binary files /dev/null and b/images/cheat_sheet_ggplot2.png differ diff --git a/index.Rmd b/index.Rmd index 07f78b4..59d12d6 100644 --- a/index.Rmd +++ b/index.Rmd @@ -16,9 +16,11 @@ biblio-style: apalike ```{r setup, echo=F,eval=T,include=FALSE} knitr::opts_chunk$set(echo = TRUE, eval = TRUE, warning = FALSE, message = FALSE) +options(knitr.duplicate.label = "allow") library(ggplot2) theme_set(theme_gray()) library(gifski) +library(savoirfR) ``` @@ -28,6 +30,26 @@ library(gifski) *Crédit photographique Sébastien Colas* +## Le parcours de formation + +```{r collecte prez parcours, results='asis', warning=FALSE, echo=FALSE} +# Utilisation du chapitre de présentation du parcours présent dans https://github.com/MTES-MCT/parcours-r +cat(stringi::stri_read_lines("https://raw.githubusercontent.com/MTES-MCT/parcours-r/master/parties_communes/le_parcours_R.Rmd", encoding = "UTF-8"), sep = "\n") +``` + + +## Le groupe de référents R du pôle ministériel + +```{r collecte prez ref, warning=FALSE, echo=FALSE, results='asis'} +# Utilisation du chapitre de présentation des référents présent dans https://github.com/MTES-MCT/parcours-r +a <- knitr::knit_child(text = stringi::stri_read_lines("https://raw.githubusercontent.com/MTES-MCT/parcours-r/master/parties_communes/les_referents_R.Rmd", encoding = "UTF-8"), quiet = TRUE) +cat(a, sep = '\n') +``` + + +## Objectifs du module 5 + + Ce module va vous permettre de découvrir un ensemble de méthodes sous R afin de produire : - Des tableaux @@ -55,3 +77,17 @@ knitr::write_bib(c( .packages(), 'bookdown', 'knitr', 'rmarkdown', 'ggplot2' ), 'packages.bib') ``` + +```{r recup dataset depuis savoirfR, message=FALSE, include=FALSE, warning=FALSE} +library(dplyr) +# récupération des jeux de données de savoir faire +datasets_m5 <- read.csv2(system.file("extdata", "list_data_module.csv", package = "savoirfR")) %>% + filter(module == "m5") %>% + pull(file) +dir.create("extdata/") +file.copy(from = system.file("extdata", datasets_m5, package = "savoirfR"), + to = paste0("extdata/", datasets_m5), overwrite = TRUE) + +``` + + diff --git a/m5_admin.R b/m5_admin.R index 40b9791..5a00d38 100644 --- a/m5_admin.R +++ b/m5_admin.R @@ -2,26 +2,55 @@ bookdown::render_book("index.Rmd", "bookdown::gitbook") +creer_pdf_book_ssp <- function (chemin_book = "_book/", nom_pdf = "book_complet.pdf", + pages_html = c("index", "Chapo", "evolparc", "caractparc", + "mouvmts", "dpe", "tension", "loyers", "methodo", "mentionslegales"), + scale = 0.9) { + if (!dir.exists(chemin_book)) { + message(glue::glue("Le repertoire {chemin_book} n'existe pas, creation au prealable de la publication au format html.")) + rmarkdown::render_site(encoding = "UTF-8") + chemin_book = "_book/" + } + else { + chemin_book <- paste0(chemin_book, ("/")) + } + pages_html <- gsub(".html$", "", pages_html) + pages_html <- paste0(chemin_book, pages_html, ".html") + pages_pdf <- gsub(".html", ".pdf", pages_html) + attempt::stop_if_any(!file.exists(pages_html), msg = glue::glue("Il manque au moins un fichier html dans {chemin_book} ou il y a probleme de nommage, revoyez l'argument 'pages_html'.")) + file.copy(from = paste0(chemin_book, "gouv_book.css"), to = paste0(chemin_book, "style.css")) + message("Export des pages html au format PDF en cours :") + impress <- function(page, echelle = scale) { + message(glue::glue("- {page}")) + pagedown::chrome_print(input = page, extra_args = c("--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage"), + verbose = 0, timeout = 600, options = list(transferMode = "ReturnAsStream", scale = echelle)) + } + purrr::map(.x = pages_html, .f = impress) + qpdf::pdf_combine(pages_pdf, output = glue::glue("{chemin_book}{nom_pdf}")) + file.remove(pages_pdf, glue::glue("{chemin_book}style.css")) + suppressWarnings(file.remove(glue::glue("{chemin_book}404.pdf"))) + message(glue::glue("Le fichier {nom_pdf} est disponible dans {chemin_book}.")) +} # Commande pour générer un support pdf du module 5 -# propre.rpls::creer_pdf_book( -# chemin_book = "_book/", nom_pdf = "M5_dataviz.pdf", -# pages_html = c( -# "index.html", -# "bien-commencer.html", -# "package-ggplot2.html", -# "le-mapping.html", -# "les-formes-géométriques.html", -# "lhabillage-simple.html", -# "les-thèmes.html", -# "les-scales.html", -# "la-mise-en-page-de-plusieurs-graphiques.html", -# "les-facettes.html", -# "exporter-un-graphique.html", -# "créer-des-cartes-avec-ggplot2.html", -# "animer-ses-graphiques-ggplot-avec-gganimate.html", -# "créer-des-graphiques-et-cartes-pour-le-web.html", -# "créer-des-tableaux-avec-kable-et-kable-extra.html", -# "ressources.html", -# "exercices-et-corrections.html" -# )) +creer_pdf_book_ssp( + chemin_book = "_book/", nom_pdf = "M5_dataviz.pdf", + pages_html = c( + "index.html", + "bien-commencer.html", + "package-ggplot2.html", + "le-mapping.html", + "les-formes-géométriques.html", + "lhabillage-simple.html", + "les-thèmes.html", + "les-scales.html", + "la-mise-en-page-de-plusieurs-graphiques.html", + "les-facettes.html", + "exporter-un-graphique.html", + "créer-des-cartes-avec-ggplot2.html", + "animer-ses-graphiques-ggplot-avec-gganimate.html", + "créer-des-graphiques-et-cartes-pour-le-web.html", + "créer-des-tableaux-avec-kable-et-kable-extra.html", + "ressources.html", + "exercices-et-corrections.html" + )) diff --git a/packages.bib b/packages.bib index 6397747..6a8d852 100644 --- a/packages.bib +++ b/packages.bib @@ -3,48 +3,137 @@ @Manual{R-base author = {{R Core Team}}, organization = {R Foundation for Statistical Computing}, address = {Vienna, Austria}, - year = {2021}, + year = {2022}, url = {https://www.R-project.org/}, } @Manual{R-bookdown, title = {bookdown: Authoring Books and Technical Documents with R Markdown}, author = {Yihui Xie}, - year = {2021}, - note = {R package version 0.24}, - url = {https://CRAN.R-project.org/package=bookdown}, + year = {2023}, + note = {R package version 0.37}, + url = {https://github.com/rstudio/bookdown}, +} + +@Manual{R-COGiter, + title = {COGiter: Fonctions, Données et Fonds de Carte pour Gérer les Données au +Territoire - COG 2023}, + author = {Maël THEULIERE}, + year = {2023}, + note = {R package version 0.0.12}, + url = {https://github.com/MaelTheuliere/COGiter}, +} + +@Manual{R-dplyr, + title = {dplyr: A Grammar of Data Manipulation}, + author = {Hadley Wickham and Romain François and Lionel Henry and Kirill Müller and Davis Vaughan}, + year = {2023}, + note = {R package version 1.1.2}, + url = {https://dplyr.tidyverse.org}, +} + +@Manual{R-forcats, + title = {forcats: Tools for Working with Categorical Variables (Factors)}, + author = {Hadley Wickham}, + year = {2023}, + note = {R package version 1.0.0}, + url = {https://forcats.tidyverse.org/}, } @Manual{R-ggplot2, title = {ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics}, author = {Hadley Wickham and Winston Chang and Lionel Henry and Thomas Lin Pedersen and Kohske Takahashi and Claus Wilke and Kara Woo and Hiroaki Yutani and Dewey Dunnington}, - year = {2021}, - note = {R package version 3.3.5}, - url = {https://CRAN.R-project.org/package=ggplot2}, + year = {2023}, + note = {R package version 3.4.4}, + url = {https://ggplot2.tidyverse.org}, } @Manual{R-gifski, title = {gifski: Highest Quality GIF Encoder}, author = {Jeroen Ooms}, - year = {2021}, - note = {R package version 1.4.3-1}, - url = {https://CRAN.R-project.org/package=gifski}, + year = {2022}, + note = {R package version 1.6.6-1}, + url = {https://gif.ski/}, } @Manual{R-knitr, title = {knitr: A General-Purpose Package for Dynamic Report Generation in R}, author = {Yihui Xie}, - year = {2021}, - note = {R package version 1.36}, + year = {2023}, + note = {R package version 1.45}, url = {https://yihui.org/knitr/}, } +@Manual{R-purrr, + title = {purrr: Functional Programming Tools}, + author = {Hadley Wickham and Lionel Henry}, + year = {2023}, + note = {R package version 1.0.1}, + url = {https://purrr.tidyverse.org/}, +} + +@Manual{R-readr, + title = {readr: Read Rectangular Text Data}, + author = {Hadley Wickham and Jim Hester and Jennifer Bryan}, + year = {2022}, + note = {R package version 2.1.3}, + url = {https://readr.tidyverse.org}, +} + @Manual{R-rmarkdown, title = {rmarkdown: Dynamic Documents for R}, - author = {JJ Allaire and Yihui Xie and Jonathan McPherson and Javier Luraschi and Kevin Ushey and Aron Atkins and Hadley Wickham and Joe Cheng and Winston Chang and Richard Iannone}, - year = {2021}, - note = {R package version 2.11}, - url = {https://CRAN.R-project.org/package=rmarkdown}, + author = {JJ Allaire and Yihui Xie and Christophe Dervieux and Jonathan McPherson and Javier Luraschi and Kevin Ushey and Aron Atkins and Hadley Wickham and Joe Cheng and Winston Chang and Richard Iannone}, + year = {2023}, + note = {R package version 2.25}, + url = {https://github.com/rstudio/rmarkdown}, +} + +@Manual{R-savoirfR, + title = {savoirfR: Exercices for mtes-mctrct r course modules}, + author = {Murielle Lethrosne and Maël Theuliere and Marouane Zellou and Bruno Terseur and Jean-Daniel LOMENEDE and Juliette Engelaere-Lefebvre}, + note = {R package version 0.0.0.9008}, + url = {https://github.com/MTES-MCT/savoirfR}, + year = {2023}, +} + +@Manual{R-sf, + title = {sf: Simple Features for R}, + author = {Edzer Pebesma}, + year = {2023}, + note = {R package version 1.0-12}, + url = {https://r-spatial.github.io/sf/}, +} + +@Manual{R-stringr, + title = {stringr: Simple, Consistent Wrappers for Common String Operations}, + author = {Hadley Wickham}, + year = {2023}, + note = {R package version 1.5.1}, + url = {https://stringr.tidyverse.org}, +} + +@Manual{R-tibble, + title = {tibble: Simple Data Frames}, + author = {Kirill Müller and Hadley Wickham}, + year = {2023}, + note = {R package version 3.2.1}, + url = {https://tibble.tidyverse.org/}, +} + +@Manual{R-tidyr, + title = {tidyr: Tidy Messy Data}, + author = {Hadley Wickham and Maximilian Girlich}, + year = {2022}, + note = {R package version 1.2.1}, + url = {https://tidyr.tidyverse.org}, +} + +@Manual{R-tidyverse, + title = {tidyverse: Easily Install and Load the Tidyverse}, + author = {Hadley Wickham}, + year = {2022}, + note = {R package version 1.3.2}, + url = {https://tidyverse.tidyverse.org}, } @Book{bookdown2016, @@ -53,7 +142,7 @@ @Book{bookdown2016 publisher = {Chapman and Hall/CRC}, address = {Boca Raton, Florida}, year = {2016}, - note = {ISBN 978-1138700109}, + isbn = {978-1138700109}, url = {https://bookdown.org/yihui/bookdown}, } @@ -85,7 +174,6 @@ @InCollection{knitr2014 publisher = {Chapman and Hall/CRC}, year = {2014}, note = {ISBN 978-1466561595}, - url = {http://www.crcpress.com/product/isbn/9781466561595}, } @Book{rmarkdown2018, @@ -94,7 +182,7 @@ @Book{rmarkdown2018 publisher = {Chapman and Hall/CRC}, address = {Boca Raton, Florida}, year = {2018}, - note = {ISBN 9781138359338}, + isbn = {9781138359338}, url = {https://bookdown.org/yihui/rmarkdown}, } @@ -104,7 +192,39 @@ @Book{rmarkdown2020 publisher = {Chapman and Hall/CRC}, address = {Boca Raton, Florida}, year = {2020}, - note = {ISBN 9780367563837}, + isbn = {9780367563837}, url = {https://bookdown.org/yihui/rmarkdown-cookbook}, } +@Article{sf2018, + author = {Edzer Pebesma}, + title = {{Simple Features for R: Standardized Support for Spatial Vector Data}}, + year = {2018}, + journal = {{The R Journal}}, + doi = {10.32614/RJ-2018-009}, + url = {https://doi.org/10.32614/RJ-2018-009}, + pages = {439--446}, + volume = {10}, + number = {1}, +} + +@Book{sf2023, + author = {Edzer Pebesma and Roger Bivand}, + title = {{Spatial Data Science: With applications in R}}, + year = {2023}, + publisher = {{Chapman and Hall/CRC}}, + url = {https://r-spatial.org/book/}, + pages = {352}, +} + +@Article{tidyverse2019, + title = {Welcome to the {tidyverse}}, + author = {Hadley Wickham and Mara Averick and Jennifer Bryan and Winston Chang and Lucy D'Agostino McGowan and Romain François and Garrett Grolemund and Alex Hayes and Lionel Henry and Jim Hester and Max Kuhn and Thomas Lin Pedersen and Evan Miller and Stephan Milton Bache and Kirill Müller and Jeroen Ooms and David Robinson and Dana Paige Seidel and Vitalie Spinu and Kohske Takahashi and Davis Vaughan and Claus Wilke and Kara Woo and Hiroaki Yutani}, + year = {2019}, + journal = {Journal of Open Source Software}, + volume = {4}, + number = {43}, + pages = {1686}, + doi = {10.21105/joss.01686}, +} + diff --git a/renv.lock b/renv.lock deleted file mode 100644 index f749712..0000000 --- a/renv.lock +++ /dev/null @@ -1,1484 +0,0 @@ -{ - "R": { - - "Version": "4.2.1", - "Repositories": [ - { - "Name": "CRAN", - "URL": "https://cran.rstudio.com" - } - ] - }, - "Packages": { - "DBI": { - "Package": "DBI", - "Version": "1.1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "030aaec5bc6553f35347cbb1e70b1a17" - }, - "KernSmooth": { - "Package": "KernSmooth", - "Version": "2.23-20", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "8dcfa99b14c296bc9f1fd64d52fd3ce7" - }, - "MASS": { - "Package": "MASS", - "Version": "7.3-54", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0e59129db205112e3963904db67fd0dc" - }, - "Matrix": { - "Package": "Matrix", - "Version": "1.3-4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "4ed05e9c9726267e4a5872e09c04587c" - }, - "MatrixModels": { - "Package": "MatrixModels", - "Version": "0.5-0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "366a8838782928e398b8762c932a42a3" - }, - "ModelMetrics": { - "Package": "ModelMetrics", - "Version": "1.2.2.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "40a55bd0b44719941d103291ac5e9d74" - }, - "R6": { - "Package": "R6", - "Version": "2.5.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "470851b6d5d0ac559e9d01bb352b4021" - }, - "RColorBrewer": { - "Package": "RColorBrewer", - "Version": "1.1-2", - "Source": "Repository", - "Repository": "RSPM", - "Hash": "e031418365a7f7a766181ab5a41a5716" - }, - "RCurl": { - "Package": "RCurl", - "Version": "1.98-1.9", - "Source": "Repository", - "Repository": "RSPM" - }, - "RPostgreSQL": { - "Package": "RPostgreSQL", - "Version": "0.7-4", - "Source": "Repository", - "Repository": "RSPM" - }, - "Rcpp": { - "Package": "Rcpp", - "Version": "1.0.7", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "dab19adae4440ae55aa8a9d238b246bb" - }, - "RcppArmadillo": { - "Package": "RcppArmadillo", - "Version": "0.10.7.3.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "82b411caa086a4f007ec43a288fba990" - }, - "RcppEigen": { - "Package": "RcppEigen", - "Version": "0.3.3.9.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "ddfa72a87fdf4c80466a20818be91d00" - }, - "Rttf2pt1": { - "Package": "Rttf2pt1", - "Version": "1.3.9", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "da6ab407fa2e5e498ac980f92798cfed" - }, - "SQUAREM": { - "Package": "SQUAREM", - "Version": "2021.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0cf10dab0d023d5b46a5a14387556891" - }, - "SparseM": { - "Package": "SparseM", - "Version": "1.81", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "2042cd9759cc89a453c4aefef0ce9aae" - }, - "TTR": { - "Package": "TTR", - "Version": "0.24.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "7e2c62de2799dc212e5b52526c288e72" - }, - "XML": { - "Package": "XML", - "Version": "3.99-0.12", - "Source": "Repository", - "Repository": "RSPM" - }, - "abind": { - "Package": "abind", - "Version": "1.4-5", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "4f57884290cc75ab22f4af9e9d4ca862" - }, - "apexcharter": { - "Package": "apexcharter", - "Version": "0.3.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "24c6548111ec574558fe7e3122d75751" - }, - "askpass": { - "Package": "askpass", - "Version": "1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "e8a22846fff485f0be3770c2da758713" - }, - "assertthat": { - "Package": "assertthat", - "Version": "0.2.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "50c838a310445e954bc13f26f26a6ecf" - }, - "backports": { - "Package": "backports", - "Version": "1.3.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "194ad71f8ed59393272a0c4be2eac215" - }, - "base64enc": { - "Package": "base64enc", - "Version": "0.1-3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "543776ae6848fde2f48ff3816d0628bc" - }, - "bookdown": { - "Package": "bookdown", - "Version": "0.24", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "3837766a1e1b527af25fa3e2d12a2800" - }, - "boot": { - "Package": "boot", - "Version": "1.3-28", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0baa960e3b49c6176a4f42addcbacc59" - }, - "broom": { - "Package": "broom", - "Version": "0.7.10", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "ddf8bc55ea050f984835dd2d23cd6828" - }, - "bslib": { - "Package": "bslib", - "Version": "0.3.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "56ae7e1987b340186a8a5a157c2ec358" - }, - "cachem": { - "Package": "cachem", - "Version": "1.0.6", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "648c5b3d71e6a37e3043617489a0a0e9" - }, - "callr": { - "Package": "callr", - "Version": "3.7.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "461aa75a11ce2400245190ef5d3995df" - }, - "car": { - "Package": "car", - "Version": "3.0-12", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "40e15704635050c063b1b26acce2051c" - }, - "carData": { - "Package": "carData", - "Version": "3.0-4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "7ff5c94cec207b3fd9774cfaa5157738" - }, - "caret": { - "Package": "caret", - "Version": "6.0-90", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "42469c788063931bd460be0c4d6044eb" - }, - "class": { - "Package": "class", - "Version": "7.3-19", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "1593b7beb067c8381c0d24e38bd778e0" - }, - "classInt": { - "Package": "classInt", - "Version": "0.4-3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "17bdfa3c51df4a6c82484d13b11fb380" - }, - "cli": { - "Package": "cli", - "Version": "3.1.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "66a3834e54593c89d8beefb312347e58" - }, - "codetools": { - "Package": "codetools", - "Version": "0.2-18", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "019388fc48e48b3da0d3a76ff94608a8" - }, - "colorspace": { - "Package": "colorspace", - "Version": "2.0-2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "6baccb763ee83c0bd313460fdb8b8a84" - }, - "commonmark": { - "Package": "commonmark", - "Version": "1.7", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0f22be39ec1d141fd03683c06f3a6e67" - }, - "conquer": { - "Package": "conquer", - "Version": "1.2.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "8225311a3d9cf63a74917bfa8167d868" - }, - "corrplot": { - "Package": "corrplot", - "Version": "0.92", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "fcf11a91936fd5047b2ee9bc00595e36" - }, - "cowplot": { - "Package": "cowplot", - "Version": "1.1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "b418e8423699d11c7f2087c2bfd07da2" - }, - "cpp11": { - "Package": "cpp11", - "Version": "0.4.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "fa53ce256cd280f468c080a58ea5ba8c" - }, - "crayon": { - "Package": "crayon", - "Version": "1.4.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0a6a65d92bd45b47b94b84244b528d17" - }, - "crosstalk": { - "Package": "crosstalk", - "Version": "1.2.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "6aa54f69598c32177e920eb3402e8293" - }, - "curl": { - "Package": "curl", - "Version": "4.3.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "022c42d49c28e95d69ca60446dbabf88" - }, - "data.table": { - "Package": "data.table", - "Version": "1.14.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "36b67b5adf57b292923f5659f5f0c853" - }, - "dichromat": { - "Package": "dichromat", - "Version": "2.0-0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "fe1a3788cf243db3eca07ae661860793" - }, - "digest": { - "Package": "digest", - "Version": "0.6.29", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "cf6b206a045a684728c3267ef7596190" - }, - "dplyr": { - "Package": "dplyr", - "Version": "1.0.7", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "36f1ae62f026c8ba9f9b5c9a08c03297" - }, - "e1071": { - "Package": "e1071", - "Version": "1.7-9", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "32885be243a29301c90d33db37c3aad8" - }, - "ellipsis": { - "Package": "ellipsis", - "Version": "0.3.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "bb0eec2fe32e88d9e2836c2f73ea2077" - }, - "evaluate": { - "Package": "evaluate", - "Version": "0.14", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "ec8ca05cffcc70569eaaad8469d2a3a7" - }, - "extrafont": { - "Package": "extrafont", - "Version": "0.17", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "7f2f50e8f998a4bea4b04650fc4f2ca8" - }, - "extrafontdb": { - "Package": "extrafontdb", - "Version": "1.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "a861555ddec7451c653b40e713166c6f" - }, - "fansi": { - "Package": "fansi", - "Version": "0.5.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "d447b40982c576a72b779f0a3b3da227" - }, - "farver": { - "Package": "farver", - "Version": "2.1.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "c98eb5133d9cb9e1622b8691487f11bb" - }, - "fastmap": { - "Package": "fastmap", - "Version": "1.1.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "77bd60a6157420d4ffa93b27cf6a58b8" - }, - "fontawesome": { - "Package": "fontawesome", - "Version": "0.2.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "55624ed409e46c5f358b2c060be87f67" - }, - "forcats": { - "Package": "forcats", - "Version": "0.5.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "81c3244cab67468aac4c60550832655d" - }, - "foreach": { - "Package": "foreach", - "Version": "1.5.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "e32cfc0973caba11b65b1fa691b4d8c9" - }, - "foreign": { - "Package": "foreign", - "Version": "0.8-81", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "74628ea7a3be5ee8a7b5bb0a8e84882e" - }, - "fs": { - "Package": "fs", - "Version": "1.5.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "8142f0a2056d53ec2e15bf701185beb1" - }, - "future": { - "Package": "future", - "Version": "1.23.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "7bf6fbed7f00cae876901fd70c04f3a4" - }, - "future.apply": { - "Package": "future.apply", - "Version": "1.8.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "f568ce73d3d59582b0f7babd0eb33d07" - }, - "gdtools": { - "Package": "gdtools", - "Version": "0.2.3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "12a524de5a491ff39debb9311fc0763f" - }, - "generics": { - "Package": "generics", - "Version": "0.1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "3f6bcfb0ee5d671d9fd1893d2faa79cb" - }, - "geojsonsf": { - "Package": "geojsonsf", - "Version": "2.0.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "8bf70c1328f68761115943b68e565dc6" - }, - "geometries": { - "Package": "geometries", - "Version": "0.2.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "be29054e97e756ade56d13a89c6d5243" - }, - "gganimate": { - "Package": "gganimate", - "Version": "1.0.7", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "729026083340f1076e622886c5b337b7" - }, - "ggiraph": { - "Package": "ggiraph", - "Version": "0.7.10", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "38b169da6947549169248a1afe549bb1" - }, - "ggplot2": { - "Package": "ggplot2", - "Version": "3.3.5", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "d7566c471c7b17e095dd023b9ef155ad" - }, - "ggpubr": { - "Package": "ggpubr", - "Version": "0.4.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "77089557d374c69db7cb77e65f0d6ab0" - }, - "ggrepel": { - "Package": "ggrepel", - "Version": "0.9.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "08ab869f37e6a7741a64ab9069bcb67d" - }, - "ggsci": { - "Package": "ggsci", - "Version": "2.9", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "81ccb8213ed592598210afd10c3a5936" - }, - "ggsignif": { - "Package": "ggsignif", - "Version": "0.6.3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "2e82e829a1c4a6c5d41921c177051e85" - }, - "ggspatial": { - "Package": "ggspatial", - "Version": "1.1.5", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "a04dadf9f113eaa67c179ec7011034e7" - }, - "gifski": { - "Package": "gifski", - "Version": "1.4.3-1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "73d7566604b51f704a2f33b2efef470c" - }, - "globals": { - "Package": "globals", - "Version": "0.14.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "eca8023ed5ca6372479ebb9b3207f5ae" - }, - "glue": { - "Package": "glue", - "Version": "1.5.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "e01bc1fe0c20954ec97eac86640abc70" - }, - "gouvdown": { - "Package": "gouvdown", - "Version": "0.0.0.9000", - "Source": "GitHub", - "Remotes": "spyrales/gouvdown.fonts", - "RemoteType": "github", - "RemoteHost": "api.github.com", - "RemoteRepo": "gouvdown", - "RemoteUsername": "Spyrales", - "RemoteRef": "HEAD", - "RemoteSha": "653f3c46cba9da09e2c648ccd1a43752eeda22e0", - "Hash": "1a4434d70709e20d46098b22d9f70d9e" - }, - "gouvdown.fonts": { - "Package": "gouvdown.fonts", - "Version": "0.0.1", - "Source": "GitHub", - "RemoteType": "github", - "RemoteHost": "api.github.com", - "RemoteRepo": "gouvdown.fonts", - "RemoteUsername": "spyrales", - "RemoteRef": "HEAD", - "RemoteSha": "d40dfe7cd22fbe9f476b7f480b6cc2a263c95264", - "Hash": "2ddbe8a5ddf28f4deed822d05d39e841" - }, - "gower": { - "Package": "gower", - "Version": "0.2.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "be6a2b3529928bd803d1c437d1d43152" - }, - "gridExtra": { - "Package": "gridExtra", - "Version": "2.3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "7d7f283939f563670a697165b2cf5560" - }, - "gtable": { - "Package": "gtable", - "Version": "0.3.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "ac5c6baf7822ce8732b343f14c072c4d" - }, - "here": { - "Package": "here", - "Version": "1.0.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "24b224366f9c2e7534d2344d10d59211" - }, - "highcharter": { - "Package": "highcharter", - "Version": "0.8.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0058e6db360b4131c268f8148df229c9" - }, - "highr": { - "Package": "highr", - "Version": "0.9", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "8eb36c8125038e648e5d111c0d7b2ed4" - }, - "hms": { - "Package": "hms", - "Version": "1.1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "5b8a2dd0fdbe2ab4f6081e6c7be6dfca" - }, - "hrbrthemes": { - "Package": "hrbrthemes", - "Version": "0.8.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0d1257948f016840ad90320ed19c8c7d" - }, - "htmltools": { - "Package": "htmltools", - "Version": "0.5.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "526c484233f42522278ab06fb185cb26" - }, - "htmlwidgets": { - "Package": "htmlwidgets", - "Version": "1.5.4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "76147821cd3fcd8c4b04e1ef0498e7fb" - }, - "httpuv": { - "Package": "httpuv", - "Version": "1.6.3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "65e865802fe6dd1bafef1dae5b80a844" - }, - "httr": { - "Package": "httr", - "Version": "1.4.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "a525aba14184fec243f9eaec62fbed43" - }, - "igraph": { - "Package": "igraph", - "Version": "1.2.9", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "66abc5ba63fe0543b3d7c5ec73b4230f" - }, - "ipred": { - "Package": "ipred", - "Version": "0.9-12", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "8312ebd8121ad2eca1c76441040bee5d" - }, - "isoband": { - "Package": "isoband", - "Version": "0.2.5", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "7ab57a6de7f48a8dc84910d1eca42883" - }, - "iterators": { - "Package": "iterators", - "Version": "1.0.13", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "64778782a89480e9a644f69aad9a2877" - }, - "jpeg": { - "Package": "jpeg", - "Version": "0.1-9", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "441ee36360a57b363f4fa3df0c364630" - }, - "jquerylib": { - "Package": "jquerylib", - "Version": "0.1.4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "5aab57a3bd297eee1c1d862735972182" - }, - "jsonify": { - "Package": "jsonify", - "Version": "1.2.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "f435875f0eb7de52ade944ed82ee9089" - }, - "jsonlite": { - "Package": "jsonlite", - "Version": "1.7.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "98138e0994d41508c7a6b84a0600cfcb" - }, - "kableExtra": { - "Package": "kableExtra", - "Version": "1.3.4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "49b625e6aabe4c5f091f5850aba8ff78" - }, - "knitr": { - "Package": "knitr", - "Version": "1.36", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "46344b93f8854714cdf476433a59ed10" - }, - "labeling": { - "Package": "labeling", - "Version": "0.4.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "3d5108641f47470611a32d0bdf357a72" - }, - "later": { - "Package": "later", - "Version": "1.3.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "7e7b457d7766bc47f2a5f21cc2984f8e" - }, - "lattice": { - "Package": "lattice", - "Version": "0.20-45", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "b64cdbb2b340437c4ee047a1f4c4377b" - }, - "lava": { - "Package": "lava", - "Version": "1.6.10", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "4c31a28528978d8689145f5274ce9058" - }, - "lazyeval": { - "Package": "lazyeval", - "Version": "0.2.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "d908914ae53b04d4c0c0fd72ecc35370" - }, - "leafem": { - "Package": "leafem", - "Version": "0.1.6", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "39682b851cfb151d02be19c5575bdc00" - }, - "leaflet": { - "Package": "leaflet", - "Version": "2.0.4.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "e3d73becdeb92754d27172d278cbf61d" - }, - "leaflet.providers": { - "Package": "leaflet.providers", - "Version": "1.9.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "d3082a7beac4a1aeb96100ff06265d7e" - }, - "leafsync": { - "Package": "leafsync", - "Version": "0.1.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "819d7169c7d39f0f952473e943375da1" - }, - "lifecycle": { - "Package": "lifecycle", - "Version": "1.0.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "a6b6d352e3ed897373ab19d8395c98d0" - }, - "listenv": { - "Package": "listenv", - "Version": "0.8.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0bde42ee282efb18c7c4e63822f5b4f7" - }, - "lme4": { - "Package": "lme4", - "Version": "1.1-27.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "c995b0405ce0894d6fe52b3e08ea9085" - }, - "lubridate": { - "Package": "lubridate", - "Version": "1.8.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "2ff5eedb6ee38fb1b81205c73be1be5a" - }, - "lwgeom": { - "Package": "lwgeom", - "Version": "0.2-10", - "Source": "Repository", - "Repository": "RSPM" - }, - "magrittr": { - "Package": "magrittr", - "Version": "2.0.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "41287f1ac7d28a92f0a286ed507928d3" - }, - "maptools": { - "Package": "maptools", - "Version": "1.1-2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "41e7097a7a02db986344eeca0d8a49ac" - }, - "markdown": { - "Package": "markdown", - "Version": "1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "61e4a10781dd00d7d81dd06ca9b94e95" - }, - "matrixStats": { - "Package": "matrixStats", - "Version": "0.61.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "b8e6221fc11247b12ab1b055a6f66c27" - }, - "mgcv": { - "Package": "mgcv", - "Version": "1.8-38", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "be3c61ffbb1e3d3b3df214d192ac5444" - }, - "mime": { - "Package": "mime", - "Version": "0.12", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "18e9c28c1d3ca1560ce30658b22ce104" - }, - "minqa": { - "Package": "minqa", - "Version": "1.2.4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "eaee7d2a6f3ed4491df868611cb064cc" - }, - "munsell": { - "Package": "munsell", - "Version": "0.5.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "6dfe8bf774944bd5595785e3229d8771" - }, - "nlme": { - "Package": "nlme", - "Version": "3.1-153", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "2d632e0d963a653a0329756ce701ecdd" - }, - "nloptr": { - "Package": "nloptr", - "Version": "1.2.2.3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "22eeb1eb7129a2ca17b8eb70b56a02fe" - }, - "nnet": { - "Package": "nnet", - "Version": "7.3-16", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "3a3dc184000bc9e6c145c4dbde4dd702" - }, - "numDeriv": { - "Package": "numDeriv", - "Version": "2016.8-1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "df58958f293b166e4ab885ebcad90e02" - }, - "openssl": { - "Package": "openssl", - "Version": "1.4.5", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "5406fd37ef0bf9b88c8a4f264d6ec220" - }, - "pROC": { - "Package": "pROC", - "Version": "1.18.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "417fd0d40479932c19faf2747817c473" - }, - "parallelly": { - "Package": "parallelly", - "Version": "1.29.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "b5f399c9ce96977e22ef32c20b6cfe87" - }, - "pbkrtest": { - "Package": "pbkrtest", - "Version": "0.5.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "b304ff5955f37b48bd30518faf582929" - }, - "pillar": { - "Package": "pillar", - "Version": "1.6.4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "60200b6aa32314ac457d3efbb5ccbd98" - }, - "pkgconfig": { - "Package": "pkgconfig", - "Version": "2.0.3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "01f28d4278f15c76cddbea05899c5d6f" - }, - "plyr": { - "Package": "plyr", - "Version": "1.8.6", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "ec0e5ab4e5f851f6ef32cd1d1984957f" - }, - "png": { - "Package": "png", - "Version": "0.1-7", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "03b7076c234cb3331288919983326c55" - }, - "polynom": { - "Package": "polynom", - "Version": "1.4-0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "c396592ecfe9e75cee1013533efafe34" - }, - "prettymapr": { - "Package": "prettymapr", - "Version": "0.2.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "670de2201dfef54ca3d43ae91d3f8df5" - }, - "prettyunits": { - "Package": "prettyunits", - "Version": "1.1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "95ef9167b75dde9d2ccc3c7528393e7e" - }, - "processx": { - "Package": "processx", - "Version": "3.5.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0cbca2bc4d16525d009c4dbba156b37c" - }, - "prodlim": { - "Package": "prodlim", - "Version": "2019.11.13", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "c243bf70db3a6631a0c8783152fb7db9" - }, - "progress": { - "Package": "progress", - "Version": "1.2.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "14dc9f7a3c91ebb14ec5bb9208a07061" - }, - "progressr": { - "Package": "progressr", - "Version": "0.9.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "ca0d80ecc29903f7579edbabd91f4199" - }, - "promises": { - "Package": "promises", - "Version": "1.2.0.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "4ab2c43adb4d4699cf3690acd378d75d" - }, - "proxy": { - "Package": "proxy", - "Version": "0.4-26", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "50b405c6419e921b9e9360cc9ebbcf2d" - }, - "ps": { - "Package": "ps", - "Version": "1.6.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "32620e2001c1dce1af49c49dccbb9420" - }, - "purrr": { - "Package": "purrr", - "Version": "0.3.4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "97def703420c8ab10d8f0e6c72101e02" - }, - "quantmod": { - "Package": "quantmod", - "Version": "0.4.18", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "d9dd45d86b5a23984ed50d5c35724702" - }, - "quantreg": { - "Package": "quantreg", - "Version": "5.86", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "28692dfa3efea8e19d29347d05f5a489" - }, - "rapidjsonr": { - "Package": "rapidjsonr", - "Version": "1.2.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "88b9f48c93d17cdb811b54079a6a414f" - }, - "rappdirs": { - "Package": "rappdirs", - "Version": "0.3.3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "5e3c5dc0b071b21fa128676560dbe94d" - }, - "raster": { - "Package": "raster", - "Version": "3.5-2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "c5df27b2de56767e7cfbc74a962ef61c" - }, - "recipes": { - "Package": "recipes", - "Version": "0.1.17", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "443951ef5d9e72a96405cbb0157bb1d4" - }, - "renv": { - "Package": "renv", - "Version": "0.14.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "30e5eba91b67f7f4d75d31de14bbfbdc" - }, - "reshape2": { - "Package": "reshape2", - "Version": "1.4.4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "bb5996d0bd962d214a11140d77589917" - }, - "rgdal": { - "Package": "rgdal", - "Version": "1.5-27", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "ab3f3a61eb777b62c1bc0d341fd1f990" - }, - "rjson": { - "Package": "rjson", - "Version": "0.2.20", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "7d597f982ee6263716b6a2f28efd29fa" - }, - "rlang": { - "Package": "rlang", - "Version": "0.4.12", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0879f5388fe6e4d56d7ef0b7ccb031e5" - }, - "rlist": { - "Package": "rlist", - "Version": "0.4.6.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "290c8ea0700d2e7258082d0025386e68" - }, - "rmarkdown": { - "Package": "rmarkdown", - "Version": "2.11", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "320017b52d05a943981272b295750388" - }, - "rosm": { - "Package": "rosm", - "Version": "0.2.5", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "2d44e9bbfe7aff5acb7583482be4096d" - }, - "rpart": { - "Package": "rpart", - "Version": "4.1-15", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "9787c1fcb680e655d062e7611cadf78e" - }, - "rprojroot": { - "Package": "rprojroot", - "Version": "2.0.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "249d8cd1e74a8f6a26194a91b47f21d1" - }, - "rstatix": { - "Package": "rstatix", - "Version": "0.7.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "aa020f8efde649badd0b2b5456e942fe" - }, - "rstudioapi": { - "Package": "rstudioapi", - "Version": "0.13", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "06c85365a03fdaf699966cc1d3cf53ea" - }, - "rvest": { - "Package": "rvest", - "Version": "1.0.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "bb099886deffecd6f9b298b7d4492943" - }, - "s2": { - "Package": "s2", - "Version": "1.0.7", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "cedf9ef196a446ee8080c14267e69410" - }, - "sass": { - "Package": "sass", - "Version": "0.4.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "50cf822feb64bb3977bda0b7091be623" - }, - "scales": { - "Package": "scales", - "Version": "1.1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "6f76f71042411426ec8df6c54f34e6dd" - }, - "selectr": { - "Package": "selectr", - "Version": "0.4-2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "3838071b66e0c566d55cc26bd6e27bf4" - }, - "sf": { - "Package": "sf", - "Version": "1.0-4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "05ff2d3c63d954272f44deff24952879" - }, - "sfheaders": { - "Package": "sfheaders", - "Version": "0.4.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "c1bd5fbd6bed3c16a20df15d9bc20c55" - }, - "shiny": { - "Package": "shiny", - "Version": "1.7.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "00344c227c7bd0ab5d78052c5d736c44" - }, - "sourcetools": { - "Package": "sourcetools", - "Version": "0.1.7", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "947e4e02a79effa5d512473e10f41797" - }, - "sp": { - "Package": "sp", - "Version": "1.4-6", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "ce8613f4e8c84ef4da9eba65b874ebe9" - }, - "stars": { - "Package": "stars", - "Version": "0.5-4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "c10644b06dcdd6a20faa383148b1e509" - }, - "stringi": { - "Package": "stringi", - "Version": "1.7.6", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "bba431031d30789535745a9627ac9271" - }, - "stringr": { - "Package": "stringr", - "Version": "1.4.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0759e6b6c0957edb1311028a49a35e76" - }, - "survival": { - "Package": "survival", - "Version": "3.2-13", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "6f0a0fadc63bc6570fe172770f15bbc4" - }, - "svglite": { - "Package": "svglite", - "Version": "2.0.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "8fb6188960bf0f90996ce52f9c2106ac" - }, - "sys": { - "Package": "sys", - "Version": "3.4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "b227d13e29222b4574486cfcbde077fa" - }, - "systemfonts": { - "Package": "systemfonts", - "Version": "1.0.3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "5be9fcf8ef6763e8cb13ab009e273a1d" - }, - "terra": { - "Package": "terra", - "Version": "1.4-20", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "2fd9b6a814d577e2e4a7d04d4e067bc0" - }, - "tibble": { - "Package": "tibble", - "Version": "3.1.6", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "8a8f02d1934dfd6431c671361510dd0b" - }, - "tidyr": { - "Package": "tidyr", - "Version": "1.1.4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "c8fbdbd9fcac223d6c6fe8e406f368e1" - }, - "tidyselect": { - "Package": "tidyselect", - "Version": "1.1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "7243004a708d06d4716717fa1ff5b2fe" - }, - "timeDate": { - "Package": "timeDate", - "Version": "3043.102", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "fde4fc571f5f61978652c229d4713845" - }, - "tinytex": { - "Package": "tinytex", - "Version": "0.35", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "1d7220fe46159fb9f5c99a44354a2bff" - }, - "tmap": { - "Package": "tmap", - "Version": "3.3-2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "a142279e592d99715f6aff644ed2ba91" - }, - "tmaptools": { - "Package": "tmaptools", - "Version": "3.1-1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "dfcb77371df343b663d6668d2d63ac35" - }, - "tweenr": { - "Package": "tweenr", - "Version": "1.0.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "6cc663f970a529dbf776f11d5bcd1a2e" - }, - "units": { - "Package": "units", - "Version": "0.7-2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "e0f85712d5371ab2841f63cdb33fe0f0" - }, - "utf8": { - "Package": "utf8", - "Version": "1.2.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "c9c462b759a5cc844ae25b5942654d13" - }, - "uuid": { - "Package": "uuid", - "Version": "1.0-3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "2097822ba5e4440b81a0c7525d0315ce" - }, - "vctrs": { - "Package": "vctrs", - "Version": "0.3.8", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "ecf749a1b39ea72bd9b51b76292261f1" - }, - "viridis": { - "Package": "viridis", - "Version": "0.6.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "ee96aee95a7a563e5496f8991e9fde4b" - }, - "viridisLite": { - "Package": "viridisLite", - "Version": "0.4.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "55e157e2aa88161bdb0754218470d204" - }, - "webshot": { - "Package": "webshot", - "Version": "0.5.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "e99d80ad34457a4853674e89d5e806de" - }, - "widgetframe": { - "Package": "widgetframe", - "Version": "0.3.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "0ee89e6cb58182d39b30a5b506e04808" - }, - "withr": { - "Package": "withr", - "Version": "2.4.3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "a376b424c4817cda4920bbbeb3364e85" - }, - "wk": { - "Package": "wk", - "Version": "0.5.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "60e191a866c5649a8f58a458f5e60edf" - }, - "xfun": { - "Package": "xfun", - "Version": "0.28", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "f7f3a61ab62cd046d307577a8ae12999" - }, - "xml2": { - "Package": "xml2", - "Version": "1.3.3", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "40682ed6a969ea5abfd351eb67833adc" - }, - "xtable": { - "Package": "xtable", - "Version": "1.8-4", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "b8acdf8af494d9ec19ccb2481a9b11c2" - }, - "xts": { - "Package": "xts", - "Version": "0.12.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "ca2fd4ad8ef78cca3aa2b30f992798a8" - }, - "yaml": { - "Package": "yaml", - "Version": "2.2.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "2826c5d9efb0a88f657c7a679c7106db" - }, - "zoo": { - "Package": "zoo", - "Version": "1.8-9", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "035d1c7c12593038c26fb1c2fd40c4d2" - } - } -} diff --git a/renv/.gitignore b/renv/.gitignore deleted file mode 100644 index 2129631..0000000 --- a/renv/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -library/ -local/ -lock/ -python/ -staging/ diff --git a/renv/activate.R b/renv/activate.R deleted file mode 100644 index 304fd90..0000000 --- a/renv/activate.R +++ /dev/null @@ -1,668 +0,0 @@ - -local({ - - # the requested version of renv - version <- "0.14.0" - - # the project directory - project <- getwd() - - # allow environment variable to control activation - activate <- Sys.getenv("RENV_ACTIVATE_PROJECT") - if (!nzchar(activate)) { - - # don't auto-activate when R CMD INSTALL is running - if (nzchar(Sys.getenv("R_INSTALL_PKG"))) - return(FALSE) - - } - - # bail if activation was explicitly disabled - if (tolower(activate) %in% c("false", "f", "0")) - return(FALSE) - - # avoid recursion - if (nzchar(Sys.getenv("RENV_R_INITIALIZING"))) - return(invisible(TRUE)) - - # signal that we're loading renv during R startup - Sys.setenv("RENV_R_INITIALIZING" = "true") - on.exit(Sys.unsetenv("RENV_R_INITIALIZING"), add = TRUE) - - # signal that we've consented to use renv - options(renv.consent = TRUE) - - # load the 'utils' package eagerly -- this ensures that renv shims, which - # mask 'utils' packages, will come first on the search path - library(utils, lib.loc = .Library) - - # check to see if renv has already been loaded - if ("renv" %in% loadedNamespaces()) { - - # if renv has already been loaded, and it's the requested version of renv, - # nothing to do - spec <- .getNamespaceInfo(.getNamespace("renv"), "spec") - if (identical(spec[["version"]], version)) - return(invisible(TRUE)) - - # otherwise, unload and attempt to load the correct version of renv - unloadNamespace("renv") - - } - - # load bootstrap tools - bootstrap <- function(version, library) { - - # attempt to download renv - tarball <- tryCatch(renv_bootstrap_download(version), error = identity) - if (inherits(tarball, "error")) - stop("failed to download renv ", version) - - # now attempt to install - status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) - if (inherits(status, "error")) - stop("failed to install renv ", version) - - } - - renv_bootstrap_tests_running <- function() { - getOption("renv.tests.running", default = FALSE) - } - - renv_bootstrap_repos <- function() { - - # check for repos override - repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) - if (!is.na(repos)) - return(repos) - - # if we're testing, re-use the test repositories - if (renv_bootstrap_tests_running()) - return(getOption("renv.tests.repos")) - - # retrieve current repos - repos <- getOption("repos") - - # ensure @CRAN@ entries are resolved - repos[repos == "@CRAN@"] <- getOption( - "renv.repos.cran", - "https://cloud.r-project.org" - ) - - # add in renv.bootstrap.repos if set - default <- c(FALLBACK = "https://cloud.r-project.org") - extra <- getOption("renv.bootstrap.repos", default = default) - repos <- c(repos, extra) - - # remove duplicates that might've snuck in - dupes <- duplicated(repos) | duplicated(names(repos)) - repos[!dupes] - - } - - renv_bootstrap_download <- function(version) { - - # if the renv version number has 4 components, assume it must - # be retrieved via github - nv <- numeric_version(version) - components <- unclass(nv)[[1]] - - methods <- if (length(components) == 4L) { - list( - renv_bootstrap_download_github - ) - } else { - list( - renv_bootstrap_download_cran_latest, - renv_bootstrap_download_cran_archive - ) - } - - for (method in methods) { - path <- tryCatch(method(version), error = identity) - if (is.character(path) && file.exists(path)) - return(path) - } - - stop("failed to download renv ", version) - - } - - renv_bootstrap_download_impl <- function(url, destfile) { - - mode <- "wb" - - # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715 - fixup <- - Sys.info()[["sysname"]] == "Windows" && - substring(url, 1L, 5L) == "file:" - - if (fixup) - mode <- "w+b" - - utils::download.file( - url = url, - destfile = destfile, - mode = mode, - quiet = TRUE - ) - - } - - renv_bootstrap_download_cran_latest <- function(version) { - - spec <- renv_bootstrap_download_cran_latest_find(version) - - message("* Downloading renv ", version, " ... ", appendLF = FALSE) - - type <- spec$type - repos <- spec$repos - - info <- tryCatch( - utils::download.packages( - pkgs = "renv", - destdir = tempdir(), - repos = repos, - type = type, - quiet = TRUE - ), - condition = identity - ) - - if (inherits(info, "condition")) { - message("FAILED") - return(FALSE) - } - - # report success and return - message("OK (downloaded ", type, ")") - info[1, 2] - - } - - renv_bootstrap_download_cran_latest_find <- function(version) { - - # check whether binaries are supported on this system - binary <- - getOption("renv.bootstrap.binary", default = TRUE) && - !identical(.Platform$pkgType, "source") && - !identical(getOption("pkgType"), "source") && - Sys.info()[["sysname"]] %in% c("Darwin", "Windows") - - types <- c(if (binary) "binary", "source") - - # iterate over types + repositories - for (type in types) { - for (repos in renv_bootstrap_repos()) { - - # retrieve package database - db <- tryCatch( - as.data.frame( - utils::available.packages(type = type, repos = repos), - stringsAsFactors = FALSE - ), - error = identity - ) - - if (inherits(db, "error")) - next - - # check for compatible entry - entry <- db[db$Package %in% "renv" & db$Version %in% version, ] - if (nrow(entry) == 0) - next - - # found it; return spec to caller - spec <- list(entry = entry, type = type, repos = repos) - return(spec) - - } - } - - # if we got here, we failed to find renv - fmt <- "renv %s is not available from your declared package repositories" - stop(sprintf(fmt, version)) - - } - - renv_bootstrap_download_cran_archive <- function(version) { - - name <- sprintf("renv_%s.tar.gz", version) - repos <- renv_bootstrap_repos() - urls <- file.path(repos, "src/contrib/Archive/renv", name) - destfile <- file.path(tempdir(), name) - - message("* Downloading renv ", version, " ... ", appendLF = FALSE) - - for (url in urls) { - - status <- tryCatch( - renv_bootstrap_download_impl(url, destfile), - condition = identity - ) - - if (identical(status, 0L)) { - message("OK") - return(destfile) - } - - } - - message("FAILED") - return(FALSE) - - } - - renv_bootstrap_download_github <- function(version) { - - enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") - if (!identical(enabled, "TRUE")) - return(FALSE) - - # prepare download options - pat <- Sys.getenv("GITHUB_PAT") - if (nzchar(Sys.which("curl")) && nzchar(pat)) { - fmt <- "--location --fail --header \"Authorization: token %s\"" - extra <- sprintf(fmt, pat) - saved <- options("download.file.method", "download.file.extra") - options(download.file.method = "curl", download.file.extra = extra) - on.exit(do.call(base::options, saved), add = TRUE) - } else if (nzchar(Sys.which("wget")) && nzchar(pat)) { - fmt <- "--header=\"Authorization: token %s\"" - extra <- sprintf(fmt, pat) - saved <- options("download.file.method", "download.file.extra") - options(download.file.method = "wget", download.file.extra = extra) - on.exit(do.call(base::options, saved), add = TRUE) - } - - message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) - - url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) - name <- sprintf("renv_%s.tar.gz", version) - destfile <- file.path(tempdir(), name) - - status <- tryCatch( - renv_bootstrap_download_impl(url, destfile), - condition = identity - ) - - if (!identical(status, 0L)) { - message("FAILED") - return(FALSE) - } - - message("OK") - return(destfile) - - } - - renv_bootstrap_install <- function(version, tarball, library) { - - # attempt to install it into project library - message("* Installing renv ", version, " ... ", appendLF = FALSE) - dir.create(library, showWarnings = FALSE, recursive = TRUE) - - # invoke using system2 so we can capture and report output - bin <- R.home("bin") - exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" - r <- file.path(bin, exe) - args <- c("--vanilla", "CMD", "INSTALL", "-l", shQuote(library), shQuote(tarball)) - output <- system2(r, args, stdout = TRUE, stderr = TRUE) - message("Done!") - - # check for successful install - status <- attr(output, "status") - if (is.numeric(status) && !identical(status, 0L)) { - header <- "Error installing renv:" - lines <- paste(rep.int("=", nchar(header)), collapse = "") - text <- c(header, lines, output) - writeLines(text, con = stderr()) - } - - status - - } - - renv_bootstrap_platform_prefix <- function() { - - # construct version prefix - version <- paste(R.version$major, R.version$minor, sep = ".") - prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-") - - # include SVN revision for development versions of R - # (to avoid sharing platform-specific artefacts with released versions of R) - devel <- - identical(R.version[["status"]], "Under development (unstable)") || - identical(R.version[["nickname"]], "Unsuffered Consequences") - - if (devel) - prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r") - - # build list of path components - components <- c(prefix, R.version$platform) - - # include prefix if provided by user - prefix <- renv_bootstrap_platform_prefix_impl() - if (!is.na(prefix) && nzchar(prefix)) - components <- c(prefix, components) - - # build prefix - paste(components, collapse = "/") - - } - - renv_bootstrap_platform_prefix_impl <- function() { - - # if an explicit prefix has been supplied, use it - prefix <- Sys.getenv("RENV_PATHS_PREFIX", unset = NA) - if (!is.na(prefix)) - return(prefix) - - # if the user has requested an automatic prefix, generate it - auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA) - if (auto %in% c("TRUE", "True", "true", "1")) - return(renv_bootstrap_platform_prefix_auto()) - - # empty string on failure - "" - - } - - renv_bootstrap_platform_prefix_auto <- function() { - - prefix <- tryCatch(renv_bootstrap_platform_os(), error = identity) - if (inherits(prefix, "error") || prefix %in% "unknown") { - - msg <- paste( - "failed to infer current operating system", - "please file a bug report at https://github.com/rstudio/renv/issues", - sep = "; " - ) - - warning(msg) - - } - - prefix - - } - - renv_bootstrap_platform_os <- function() { - - sysinfo <- Sys.info() - sysname <- sysinfo[["sysname"]] - - # handle Windows + macOS up front - if (sysname == "Windows") - return("windows") - else if (sysname == "Darwin") - return("macos") - - # check for os-release files - for (file in c("/etc/os-release", "/usr/lib/os-release")) - if (file.exists(file)) - return(renv_bootstrap_platform_os_via_os_release(file, sysinfo)) - - # check for redhat-release files - if (file.exists("/etc/redhat-release")) - return(renv_bootstrap_platform_os_via_redhat_release()) - - "unknown" - - } - - renv_bootstrap_platform_os_via_os_release <- function(file, sysinfo) { - - # read /etc/os-release - release <- utils::read.table( - file = file, - sep = "=", - quote = c("\"", "'"), - col.names = c("Key", "Value"), - comment.char = "#", - stringsAsFactors = FALSE - ) - - vars <- as.list(release$Value) - names(vars) <- release$Key - - # get os name - os <- tolower(sysinfo[["sysname"]]) - - # read id - id <- "unknown" - for (field in c("ID", "ID_LIKE")) { - if (field %in% names(vars) && nzchar(vars[[field]])) { - id <- vars[[field]] - break - } - } - - # read version - version <- "unknown" - for (field in c("UBUNTU_CODENAME", "VERSION_CODENAME", "VERSION_ID", "BUILD_ID")) { - if (field %in% names(vars) && nzchar(vars[[field]])) { - version <- vars[[field]] - break - } - } - - # join together - paste(c(os, id, version), collapse = "-") - - } - - renv_bootstrap_platform_os_via_redhat_release <- function() { - - # read /etc/redhat-release - contents <- readLines("/etc/redhat-release", warn = FALSE) - - # infer id - id <- if (grepl("centos", contents, ignore.case = TRUE)) - "centos" - else if (grepl("redhat", contents, ignore.case = TRUE)) - "redhat" - else - "unknown" - - # try to find a version component (very hacky) - version <- "unknown" - - parts <- strsplit(contents, "[[:space:]]")[[1L]] - for (part in parts) { - - nv <- tryCatch(numeric_version(part), error = identity) - if (inherits(nv, "error")) - next - - version <- nv[1, 1] - break - - } - - paste(c("linux", id, version), collapse = "-") - - } - - renv_bootstrap_library_root_name <- function(project) { - - # use project name as-is if requested - asis <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT_ASIS", unset = "FALSE") - if (asis) - return(basename(project)) - - # otherwise, disambiguate based on project's path - id <- substring(renv_bootstrap_hash_text(project), 1L, 8L) - paste(basename(project), id, sep = "-") - - } - - renv_bootstrap_library_root <- function(project) { - - path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA) - if (!is.na(path)) - return(path) - - path <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA) - if (!is.na(path)) { - name <- renv_bootstrap_library_root_name(project) - return(file.path(path, name)) - } - - prefix <- renv_bootstrap_profile_prefix() - paste(c(project, prefix, "renv/library"), collapse = "/") - - } - - renv_bootstrap_validate_version <- function(version) { - - loadedversion <- utils::packageDescription("renv", fields = "Version") - if (version == loadedversion) - return(TRUE) - - # assume four-component versions are from GitHub; three-component - # versions are from CRAN - components <- strsplit(loadedversion, "[.-]")[[1]] - remote <- if (length(components) == 4L) - paste("rstudio/renv", loadedversion, sep = "@") - else - paste("renv", loadedversion, sep = "@") - - fmt <- paste( - "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", - "Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", - "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", - sep = "\n" - ) - - msg <- sprintf(fmt, loadedversion, version, remote) - warning(msg, call. = FALSE) - - FALSE - - } - - renv_bootstrap_hash_text <- function(text) { - - hashfile <- tempfile("renv-hash-") - on.exit(unlink(hashfile), add = TRUE) - - writeLines(text, con = hashfile) - tools::md5sum(hashfile) - - } - - renv_bootstrap_load <- function(project, libpath, version) { - - # try to load renv from the project library - if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) - return(FALSE) - - # warn if the version of renv loaded does not match - renv_bootstrap_validate_version(version) - - # load the project - renv::load(project) - - TRUE - - } - - renv_bootstrap_profile_load <- function(project) { - - # if RENV_PROFILE is already set, just use that - profile <- Sys.getenv("RENV_PROFILE", unset = NA) - if (!is.na(profile) && nzchar(profile)) - return(profile) - - # check for a profile file (nothing to do if it doesn't exist) - path <- file.path(project, "renv/local/profile") - if (!file.exists(path)) - return(NULL) - - # read the profile, and set it if it exists - contents <- readLines(path, warn = FALSE) - if (length(contents) == 0L) - return(NULL) - - # set RENV_PROFILE - profile <- contents[[1L]] - if (nzchar(profile)) - Sys.setenv(RENV_PROFILE = profile) - - profile - - } - - renv_bootstrap_profile_prefix <- function() { - profile <- renv_bootstrap_profile_get() - if (!is.null(profile)) - return(file.path("renv/profiles", profile)) - } - - renv_bootstrap_profile_get <- function() { - profile <- Sys.getenv("RENV_PROFILE", unset = "") - renv_bootstrap_profile_normalize(profile) - } - - renv_bootstrap_profile_set <- function(profile) { - profile <- renv_bootstrap_profile_normalize(profile) - if (is.null(profile)) - Sys.unsetenv("RENV_PROFILE") - else - Sys.setenv(RENV_PROFILE = profile) - } - - renv_bootstrap_profile_normalize <- function(profile) { - - if (is.null(profile) || profile %in% c("", "default")) - return(NULL) - - profile - - } - - # load the renv profile, if any - renv_bootstrap_profile_load(project) - - # construct path to library root - root <- renv_bootstrap_library_root(project) - - # construct library prefix for platform - prefix <- renv_bootstrap_platform_prefix() - - # construct full libpath - libpath <- file.path(root, prefix) - - # attempt to load - if (renv_bootstrap_load(project, libpath, version)) - return(TRUE) - - # load failed; inform user we're about to bootstrap - prefix <- paste("# Bootstrapping renv", version) - postfix <- paste(rep.int("-", 77L - nchar(prefix)), collapse = "") - header <- paste(prefix, postfix) - message(header) - - # perform bootstrap - bootstrap(version, libpath) - - # exit early if we're just testing bootstrap - if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) - return(TRUE) - - # try again to load - if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { - message("* Successfully installed and loaded renv ", version, ".") - return(renv::load()) - } - - # failed to download or load renv; warn the user - msg <- c( - "Failed to find an renv installation: the project will not be loaded.", - "Use `renv::activate()` to re-initialize the project." - ) - - warning(paste(msg, collapse = "\n"), call. = FALSE) - -}) diff --git a/renv/settings.dcf b/renv/settings.dcf deleted file mode 100644 index fc4e479..0000000 --- a/renv/settings.dcf +++ /dev/null @@ -1,8 +0,0 @@ -external.libraries: -ignored.packages: -package.dependency.fields: Imports, Depends, LinkingTo -r.version: -snapshot.type: implicit -use.cache: TRUE -vcs.ignore.library: TRUE -vcs.ignore.local: TRUE