-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path01-get-started.Rmd
97 lines (75 loc) · 3.38 KB
/
01-get-started.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Bien commencer {#get-started}
## Créer un projet sous Rstudio pour vous permettre de recenser vos travaux.
```{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')
```
## Utilisation du package `{savoirfR}`
```{r collecte prez savoirfR, warning=FALSE, echo=FALSE, results='asis'}
# Utilisation du chapitre de présentation de savoirfR 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/savoir_faire.Rmd", encoding = "UTF-8"), quiet = TRUE)
cat(a, sep = '\n')
```
## Créer votre arborescence de projet
- Créer un répertoire `/src` où vous mettrez vos scripts R.
- Créer un répertoire `/figures` où vous mettrez vos illustrations issues de R.
## Activer les packages nécessaires
Commencez par rajouter un script dans le répertoire `/src` à votre projet qui commencera par :
- activez l'ensemble des packages nécessaires,
- chargez les données dont vous aurez besoin.
```{r all_packages}
# remotes::install_github("joelgombin/banR")
library(banR)
# remotes::install_github("antuki/CARTElette/CARTElette@RPackage")
library(CARTElette)
library(cartogram)
# remotes::install_github("MaelTheuliere/COGiter")
library(COGiter)
library(cowplot)
# remotes::install_gitlab('dreal-pdl/csd/datalibaba', host = "gitlab-forge.din.developpement-durable.gouv.fr")
library(datalibaba)
library(DT)
library(ggiraph)
library(ggspatial)
library(glue)
# remotes::install_github("spyrales/gouvdown")
library(gouvdown)
# remotes::install_github("spyrales/gouvdown.fonts")
library(gouvdown.fonts)
library(htmltools)
library(htmlwidgets)
library(jsonlite)
library(kableExtra)
library(knitr)
library(leaflet)
library(lubridate)
# remotes::install_gitlab('dreal-pdl/csd/mapfactory', host = "gitlab-forge.din.developpement-durable.gouv.fr")
library(mapfactory)
library(mapview)
library(osmdata)
library(osmextract)
library(osrm)
library(rmapshaper)
library(RPostgres)
library(savoirfR)
library(scales)
library(sf)
library(spData)
library(tidyverse) # comprend ggplot2, stringr, purrr, readr, httr
library(tmap)
library(tmaptools)
# remotes::install_github("MaelTheuliere/variousdata")
library(variousdata)
library(viridis)
load("extdata/admin_express.RData")
load("extdata/sirene.RData")
prefectures <- read_csv2("extdata/prefecture.csv")
```
## Bien structurer ses projets data
Plusieurs documents peuvent vous inspirer sur la structuration de vos projets data par la suite.
En voici quelques uns :
- https://github.com/pavopax/new-project-template
- https://nicercode.github.io/blog/2013-04-05-projects/
- https://www.inwt-statistics.com/read-blog/a-meaningful-file-structure-for-r-projects.html
- http://projecttemplate.net/architecture.html
A partir du moment où quelques grands principes sont respectés (un répertoire pour les données brutes en lecture seule par exemple), le reste est surtout une question d'attirance plus forte pour l'une ou l'autre solution. L'important est de vous tenir ensuite à garder toujours la même structure dans vos projets afin de vous y retrouver plus simplement.