Commit 61ba101c authored by Grelot Frederic's avatar Grelot Frederic :swimmer_tone5:
Browse files

Préparation so.ii v1.0.24.0

Showing with 28 additions and 12 deletions
+28 -12
so.ii Version: 1.0.23.0 so.ii Version: 1.0.24.0
0 errors ✔ | 0 warnings ✔ | 0 notes ✔ 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
**Note de version** **Note de version**
* ajout de la fonction kable * modification de map_so_ii
* ajout de la fonction linesep
**Détails** **Détails**
* kable masque knitr::kable en ajoutant des options très souvent utilisées * map_so_ii charge dorénavant sf si besoin, modifie le parmètre sf_use_s2 à
dans l'équipe (rapport ou présentation). FALSE (de façon momentanée). Il gère aussi le format de dataset. Il cherche
* linesep permet de créer facilement des vecteurs pour ajouter des à le transformer en objet de classe sfc, s'il n'y arrive pas il renvoie un
séparation avec l'option (non documentée) linesep de kable. warning et n'affiche pas dataset.
# git tag -a v1.0.23.0 -F dev/tag-message # git tag -a v1.0.24.0 -F dev/tag-message
# git push --tags # git push --tags
^data-common$
^data-raw$ ^data-raw$
^data-raw/data-common$$
^dev$ ^dev$
^doc$ ^doc$
^Meta$ ^Meta$
......
Package: so.ii Package: so.ii
Title: Utilities very useful to share within so_ii team Title: Utilities very useful to share within so_ii team
Version: 1.0.23.0 Version: 1.0.24.0
Authors@R: Authors@R:
c( c(
person(given = "Frédéric", person(given = "Frédéric",
...@@ -23,6 +23,7 @@ LazyData: true ...@@ -23,6 +23,7 @@ LazyData: true
Imports: Imports:
kableExtra, kableExtra,
knitr, knitr,
methods,
readODS, readODS,
rio, rio,
scales, scales,
......
...@@ -151,6 +151,10 @@ map_so_ii = function( ...@@ -151,6 +151,10 @@ map_so_ii = function(
add = FALSE, add = FALSE,
... ...
) { ) {
requireNamespace("sf")
osf = suppressMessages(sf::sf_use_s2(FALSE))
on.exit(suppressMessages(sf::sf_use_s2(osf)))
theme = match.arg(theme) theme = match.arg(theme)
if (!is.null(path)) { if (!is.null(path)) {
...@@ -185,7 +189,7 @@ map_so_ii = function( ...@@ -185,7 +189,7 @@ map_so_ii = function(
), ),
stop(sprintf("%s not recognized", tolower(tools::file_ext(path)))) stop(sprintf("%s not recognized", tolower(tools::file_ext(path))))
) )
on.exit(grDevices::dev.off()) on.exit(grDevices::dev.off(), add = TRUE, after = TRUE)
} else { } else {
on.exit( on.exit(
switch( switch(
...@@ -219,7 +223,8 @@ map_so_ii = function( ...@@ -219,7 +223,8 @@ map_so_ii = function(
height = height / 2.54 height = height / 2.54
), ),
stop(sprintf("%s not recognized", tolower(tools::file_ext(path)))) stop(sprintf("%s not recognized", tolower(tools::file_ext(path))))
) ),
add = TRUE, after = TRUE
) )
on.exit(grDevices::dev.off(), add = TRUE, after = TRUE) on.exit(grDevices::dev.off(), add = TRUE, after = TRUE)
} }
...@@ -265,7 +270,16 @@ map_so_ii = function( ...@@ -265,7 +270,16 @@ map_so_ii = function(
) )
## Plot dataset if any ## Plot dataset if any
if (!missing(dataset)) plot(dataset[["geometry"]], add = TRUE, ...) if (!missing(dataset)) {
if (methods::is(dataset, "sf")) {
dataset = dataset[["geometry"]]
}
if (! methods::is(dataset, "sfc")) {
warning("'dataset' is not a sf or sfc object. It is not plotted.")
} else {
plot(dataset, add = TRUE, ...)
}
}
## Make scope visible ## Make scope visible
if (limit == TRUE) { if (limit == TRUE) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment