Commit 6d971a40 authored by Grelot Frederic's avatar Grelot Frederic :swimmer_tone5:
Browse files

Préparation de la version de la library so.ii 1.0.23.0

Showing with 145 additions and 23 deletions
+145 -23
so.ii Version: 1.0.22.0
so.ii Version: 1.0.23.0
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
**Note de version**
* ajout de l'option scope à map_so_ii
* adaptation de l'option inset
* adaptation de l'option bar
* ajout de la fonction kable
* ajout de la fonction linesep
**Détails**
* l'option "scope" (character) de map_so_ii permet de définir le scope de la
carte :
* si l'option est à "so-ii" (défaut), le périmètre total est affiché.
C'est le même comportement que précédemment.
* si l'option est un vecteur différent de "so-ii", alors il est cherché
l'ensemble des communes de so-ii dont le code INSEE correspond aux
valeurs de scope. Seules les bonnes valeurs sont gardées. Si aucune
bonne valeur n'est trouvée, un avertissement est lancé et la valeur par
d'afut est prise
* l'option "inset" permet de choisir la valeur "so-ii" pour situer un scope
plus petit que le périmètre total à l'intérieur de so-ii.
* l'option "bar" n'est pas mofifiée dans son appel, mais dans son
implémentation pour permettre d'ajuster la taille de la barre au scope
choisi.
* kable masque knitr::kable en ajoutant des options très souvent utilisées
dans l'équipe (rapport ou présentation).
* linesep permet de créer facilement des vecteurs pour ajouter des
séparation avec l'option (non documentée) linesep de kable.
# git tag -a v1.0.22.0 -F dev/tag-message
# git tag -a v1.0.23.0 -F dev/tag-message
# git push --tags
Package: so.ii
Title: Utilities very useful to share within so_ii team
Version: 1.0.22.0
Version: 1.0.23.0
Authors@R:
c(
person(given = "Frédéric",
......
......@@ -4,6 +4,8 @@ export(add_inset)
export(current_version)
export(estimate_catnat_freq)
export(format_presence)
export(kable)
export(kable_units)
export(linesep)
export(map_so_ii)
export(plot_legend)
#' @title Replace kable from kniter with some useful preset options
#'
#' @param data object, something to be transform in a table
#' @param ... some parameters that will be used in original kable
#'
#' @return Somthing to be used as a table in latex format
#'
#' @export
#'
#' @encoding UTF-8
#'
#' @author Frédéric Grelot
#'
#' @examples
#'
#' temp = head(iris)[c(5, 1:4)]
#' temp[["Species"]] = as.character(temp[["Species"]])
#' kable(temp)
#' temp = rbind(temp, c(Species = "mean", as.list(colMeans(temp[-1]))))
#' kable(temp, -1)
#' temp = rbind(temp, c("units", "mm", "mm", "mm", "mm"))
#' kable(temp, -1)
kable = function(data, ...) {
knitr::kable(
data,
format = "latex",
booktabs = TRUE,
digits = 2,
format.args = list(big.mark = " ", scientific = FALSE, digit = 2),
...
) |>
kableExtra::kable_styling(position = "center")
}
\ No newline at end of file
......@@ -11,7 +11,8 @@
#' @export
#'
#' @encoding UTF-8
#' @author This is an adaptation of the function inset of the terra package.
#'
#' @author Frédéric Grelot
#'
#' @examples
#'
......
#' @title Create a linesep for kable
#'
#' @param x vector, either numerical or logical, position for separation
#' @param n integer, length of result
#'
#' @return A character vector of linesep to be used un kable.
#'
#' @export
#'
#' @encoding UTF-8
#' @author This is an adaptation of the function inset of the terra package.
#'
#' @examples
#'
#' temp = iris[sample(seq_len(nrow(iris)), 10),]
#' kable(temp, linesep = linesep(diff(as.integer(temp[["Species"]])) != 0))
#' kable(temp, linesep = linesep(temp[["Species"]][-1] != temp[["Species"]][-nrow(temp)]))
#'
#' temp = temp[order(temp[["Species"]]), ]
#' kable(temp, linesep = linesep(cumsum(table(temp[["Species"]]))))
linesep = function(x, n) {
x = if (is.logical(x)) which(x) else as.integer(x)
if (missing(n)) n = max(x)
result = rep("", n)
result[x[x > 0]] = "\\midrule"
result[n + x[x < 0]] = "\\midrule"
return(result)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/kable.R
\encoding{UTF-8}
\name{kable}
\alias{kable}
\title{Replace kable from kniter with some useful preset options}
\usage{
kable(data, ...)
}
\arguments{
\item{data}{object, something to be transform in a table}
\item{...}{some parameters that will be used in original kable}
}
\value{
Somthing to be used as a table in latex format
}
\description{
Replace kable from kniter with some useful preset options
}
\examples{
temp = head(iris)[c(5, 1:4)]
temp[["Species"]] = as.character(temp[["Species"]])
kable(temp)
temp = rbind(temp, c(Species = "mean", as.list(colMeans(temp[-1]))))
kable(temp, -1)
temp = rbind(temp, c("units", "mm", "mm", "mm", "mm"))
kable(temp, -1)
}
\author{
Frédéric Grelot
}
......@@ -35,5 +35,5 @@ temp = rbind(temp, c("units", "mm", "mm", "mm", "mm"))
kable_units(temp, -1)
}
\author{
This is an adaptation of the function inset of the terra package.
Frédéric Grelot
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/linesep.R
\encoding{UTF-8}
\name{linesep}
\alias{linesep}
\title{Create a linesep for kable}
\usage{
linesep(x, n)
}
\arguments{
\item{x}{vector, either numerical or logical, position for separation}
\item{n}{integer, length of result}
}
\value{
A character vector of linesep to be used un kable.
}
\description{
Create a linesep for kable
}
\examples{
temp = iris[sample(seq_len(nrow(iris)), 10),]
kable(temp, linesep = linesep(diff(as.integer(temp[["Species"]])) != 0))
kable(temp, linesep = linesep(temp[["Species"]][-1] != temp[["Species"]][-nrow(temp)]))
temp = temp[order(temp[["Species"]]), ]
kable(temp, linesep = linesep(cumsum(table(temp[["Species"]]))))
}
\author{
This is an adaptation of the function inset of the terra package.
}
......@@ -126,7 +126,8 @@ If inset is not NULL, an inset will be plotted, depending on the value of
as.character(inset). Non-case sensitive partial matching is used, with "é"
interpreted as "e".
\itemize{
\item{\strong{so-ii}: scope perimeter is located within so-ii.}
\item{\strong{so-ii}: scope perimeter is located within so-ii. Only
useful when scope is less than so-ii.}
\item{\strong{department}: scope perimeter is located within Hérault
departement, if inset may be interpreted as "department", "département",
"hérault", "34".}
......
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