From 290fbc79a3d53c43d8005be944a01822e32248c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Grelot?= <frederic.grelot@irstea.fr>
Date: Thu, 27 Jan 2022 09:55:29 +0100
Subject: [PATCH] =?UTF-8?q?geau=20Version=201.0.14.0=200=20errors=20?=
 =?UTF-8?q?=E2=9C=94=20|=200=20warnings=20=E2=9C=94=20|=200=20notes=20?=
 =?UTF-8?q?=E2=9C=94?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- ajout de la fonction format_presence
	- formattage en md d'un tableau de présence pour Mattermost !
---
 geau/DESCRIPTION            |  3 ++-
 geau/NAMESPACE              |  1 +
 geau/R/format_presence.R    | 17 +++++++++++++++++
 geau/R/map_so_ii.r          |  2 +-
 geau/man/format_presence.Rd | 21 +++++++++++++++++++++
 5 files changed, 42 insertions(+), 2 deletions(-)
 create mode 100644 geau/R/format_presence.R
 create mode 100644 geau/man/format_presence.Rd

diff --git a/geau/DESCRIPTION b/geau/DESCRIPTION
index 108a33a..c688320 100644
--- a/geau/DESCRIPTION
+++ b/geau/DESCRIPTION
@@ -1,6 +1,6 @@
 Package: geau
 Title: Utilities very useful to share within geau-inondation team
-Version: 1.0.14.0
+Version: 1.0.15.0
 Authors@R:
     c(
         person(given = "Frédéric",
@@ -23,6 +23,7 @@ LazyData: true
 Imports:
     kableExtra,
     knitr,
+    readODS,
     rio,
     scales,
     sf,
diff --git a/geau/NAMESPACE b/geau/NAMESPACE
index f4d57d0..879c502 100644
--- a/geau/NAMESPACE
+++ b/geau/NAMESPACE
@@ -3,5 +3,6 @@
 export(add.inset)
 export(current_version)
 export(estimate_catnat_freq)
+export(format_presence)
 export(kable_units)
 export(map_so_ii)
diff --git a/geau/R/format_presence.R b/geau/R/format_presence.R
new file mode 100644
index 0000000..87954fc
--- /dev/null
+++ b/geau/R/format_presence.R
@@ -0,0 +1,17 @@
+#' @title Transform ods table presence in md table (for Mattermost)
+#'
+#' @param x character or data.frame, path of the ods table or the table itself
+#'
+#' @return character, md version of table behind x.
+#' 
+#' @export
+#'
+#' @encoding UTF-8
+#' @author Frédéric Grelot
+ 
+format_presence = function(x) {
+    result = if (is.character(x)) readODS::read_ods(x[1]) else x
+    result[]  = lapply(result, gsub, pattern = "B", replacement = "**B**")
+    result[]  = lapply(result, gsub, pattern = "C", replacement = "*C*")
+    knitr::kable(result, align = c("l", rep("c", length(result) - 1)))
+}
diff --git a/geau/R/map_so_ii.r b/geau/R/map_so_ii.r
index b86b5c9..a053910 100644
--- a/geau/R/map_so_ii.r
+++ b/geau/R/map_so_ii.r
@@ -122,7 +122,7 @@ map_so_ii = function(
 
     ## Init map
     graphics::par(mai = c(.65, .60, .50, .15))
-    plot(geau::so_ii_limit, axes = TRUE)
+    plot(geau::so_ii_limit, axes = TRUE, main = list(...)[["main"]], cex.main = 3)
 
     ## Plot theme if any, return theme_legend
     theme_legend = switch(
diff --git a/geau/man/format_presence.Rd b/geau/man/format_presence.Rd
new file mode 100644
index 0000000..ca96940
--- /dev/null
+++ b/geau/man/format_presence.Rd
@@ -0,0 +1,21 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/presence.R
+\encoding{UTF-8}
+\name{format_presence}
+\alias{format_presence}
+\title{Transform ods table presence in md table (for Mattermost)}
+\usage{
+format_presence(x)
+}
+\arguments{
+\item{x}{character or data.frame, path of the ods table or the table itself}
+}
+\value{
+character, md version of table behind x.
+}
+\description{
+Transform ods table presence in md table (for Mattermost)
+}
+\author{
+Frédéric Grelot
+}
-- 
GitLab