knitr::opts_chunk$set(echo = TRUE,
                      message = FALSE)
R.utils::copyDirectory("./pics",
              "./pics_resized",
              private = FALSE, recursive=TRUE)
with_def <- (function() {

  glossary <- yaml::read_yaml("resources/glossary.yml")
  glossary <- as.data.frame(do.call(rbind, glossary), stringsAsFactors = FALSE)

  function(term, def) {
    if (missing(def)) {
      def <- unlist(glossary[glossary$name == tolower(term), "desc"])
      # quick and dirty pour aussi matcher les pluriels
      if (length(def) == 0) def <- unlist(glossary[paste0(glossary$name, "s") == tolower(term), "desc"])
      # quick and dirty pour aussi matcher les infinitif
      if (length(def) == 0) def <- unlist(glossary[paste0(glossary$name, "r") == tolower(term), "desc"])
    }
    sprintf('<abbr title="%s"><b>%s</b></abbr>', def, term)
  }

})()

Adding an RMarkdown Template

This file is a minimal working example to test a few rendering properties of our package.

::: auteurs utilitr package has been created by Lino Galiana and Olivier Meslin :::

::: recommandation This box recommands a few things :::

::: conseil This box gives some advices :::

::: remarque You can also embed some remarks here :::

::: specificite Work at Insee is awesome :::

Definitions embedded in abbr class will render differently in HTML and PDF format

Time to test the code layout

This is some inline code with a long sentence. A very very very very very very very very very very very very very very long sentence.

This is a chunk :

1+1
usethis::use_git()

Test the image layout

This is some new text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.

utilitr::include_image("pics/Rlogo.png", compression = FALSE)
library(fontawesome)
library(magrittr)

texte_recommandation <- "Ce paragraphe présente succinctement les outils et les approches les plus adaptés à la tâche concernée. Chaque fiche ne comprend qu'un seul paragraphe de ce type, au début de la fiche."
texte_conseil        <- "Ce paragraphe détaille les bonnes pratiques à adopter."
texte_remarque       <- "Ce paragraphe donne des informations supplémentaires ou formule une mise en garde."
texte_specificite    <- "Ce paragraphe porte sur une spécificité de l'Insee qui a un impact sur l'usage de `R`."

symb <-
  c(fa("hand-point-right", fill = "rgba(220, 53, 69, 1)", height = "40px"),
    fa("lightbulb", fill = "rgba(255, 193, 7, 1)", height = "40px"),
    fa("info-circle", fill = "rgba(0, 123, 255, 1)", height = "40px"),
    fa("home", fill = "rgba(81, 81, 81, 1)", height = "40px"))

dt <- 
  as.data.frame(list(
    Nom = c("Recommandation", 
            "Conseil", 
            "Remarque",
            "Spécificité Insee"), 
    Symbole = symb,
    Signification = c(texte_recommandation, 
                      texte_conseil, 
                      texte_remarque,
                      texte_specificite)
  )
  )


output <- 
  dt %>% 
  knitr::kable(escape = F, position = "center", full_width = F, align="ccl") %>%
  kableExtra::column_spec(1, width = "3cm", bold = TRUE) %>%
  kableExtra::column_spec(2, width = "2cm") %>% 
  kableExtra::column_spec(3, width = "10cm") %>% 
  kableExtra::row_spec(0,bold=TRUE, align = "c")
output


InseeFrLab/utilitr-template documentation built on Oct. 21, 2022, 11:42 p.m.