Commit 57159e7e authored by David Carayon's avatar David Carayon
Browse files

added first template

parent 61a0abcc
^InraeThemes\.Rproj$
^\.Rproj\.user$
^README\.Rmd$
^LICENSE\.md$
Package: InraeThemes
Title: What the Package Does (One Line, Title Case)
Title: Modèles et thèmes INRAE
Version: 0.0.0.9000
Authors@R:
person(given = "First",
family = "Last",
c(
person(given = "David",
family = "Carayon",
role = c("aut", "cre"),
email = "first.last@example.com",
comment = c(ORCID = "YOUR-ORCID-ID"))
Description: What the package does (one paragraph).
License: `use_mit_license()`, `use_gpl3_license()` or friends to
pick a license
email = "david.carayon@inrae.fr"),
person(given = "Sébastien",
family = "Boutry",
role = c("aut"),
email = "sebastien.boutry@inrae.fr"))
Description: Ce package met à disposition des modèles de document ainsi que des thèmes ggplot suivant la charte graphique INRAE.
License: GPL-3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.0
Depends:
R (>= 2.10)
Imports:
ggplot2,
gt,
pagedown,
rmarkdown
This diff is collapsed.
# Generated by roxygen2: do not edit by hand
export(scale_color_inrae)
export(scale_color_inrae_n5)
export(scale_colour_inrae)
export(scale_colour_inrae_n5)
export(scale_fill_inrae)
export(scale_fill_inrae_n5)
export(theme_inrae)
export(theme_inrae_1)
#' Title
#'
#' @param ...
#'
#' @return
#' @export
#'
#' @examples
scale_fill_inrae <- function(...){
library(scales)
discrete_scale("fill","inrae",manual_pal(values = c("#00a3a6","#275662","#66c1bf","#008c8e")), ...)
}
#' Title
#'
#' @param ...
#'
#' @return
#' @export
#'
#' @examples
scale_color_inrae <- function(...){
library(scales)
discrete_scale("color","inrae",manual_pal(values = c("#00a3a6","#275662","#66c1bf","#008c8e")), ...)
}
#' Title
#'
#' @param ...
#'
#' @return
#' @export
#'
#' @examples
scale_colour_inrae <- function(...){
library(scales)
discrete_scale("colour","inrae",manual_pal(values = c("#00a3a6","#275662","#66c1bf","#008c8e")), ...)
}
#' Title
#'
#' @param ...
#'
#' @return
#' @export
#'
#' @examples
scale_fill_inrae_n5 <- function(...){
library(scales)
discrete_scale("fill","inrae",manual_pal(values = c("#275662","#008C56","#66C1BF","#9ED6E3","#C4C0B3")), ...)
}
#' Title
#'
#' @param ...
#'
#' @return
#' @export
#'
#' @examples
scale_color_inrae_n5 <- function(...){
library(scales)
discrete_scale("color","inrae",manual_pal(values = c("#275662","#008C56","#66C1BF","#9ED6E3","#C4C0B3")), ...)
}
#' Title
#'
#' @param ...
#'
#' @return
#' @export
#'
#' @examples
scale_colour_inrae_n5 <- function(...){
library(scales)
discrete_scale("colour","inrae",manual_pal(values = c("#275662","#008C56","#66C1BF","#9ED6E3","#C4C0B3")), ...)
}
#' Title
#'
#' @return
#' @export
#'
#' @examples
theme_inrae <- function(){
theme(
axis.title = element_text(
family = "Avenir Next Pro",
size = 13,
color = "#275662",
face = "bold"
),
legend.title = element_text(
family = "Raleway",
size = 13,
color = "#275662",
face = "bold"
),
axis.text = element_text(
family = "Avenir Next Pro",
size = 13,
color = "#275662"
),
legend.text = element_text(
family = "Avenir Next Pro",
size = 13,
color = "#275662"
),
legend.position = "top",
strip.text = element_text(
family = "Avenir Next Pro",
size = 13,
color = "#275662"
),
plot.title = element_text(
family = "Raleway",
size = 20,
color = "#275662"
),
plot.subtitle = element_text(
family = "Raleway",
size = 16,
color = "#275662"
),
plot.caption = element_text(
family = "Avenir Next Pro",
size = 10,
color = "#275662",
hjust = -0.12
),
panel.background = element_rect(
color = "#275662",
fill = "white"
),
panel.grid.major.y = element_line(
color = "grey",
size = 0.3
),
panel.grid.minor.y = element_line(
color = "grey",
size = 0.3,
linetype = "dashed"
),
panel.grid.minor.x = element_line(
color = "grey",
size = 0.3,
linetype = "dashed"
)
)
}
#' Title
#'
#' @param base_size
#' @param base_family
#'
#' @return
#' @export
#'
#' @examples
theme_inrae_1 <- function(base_size = 10, base_family = "Avenir Next Pro") {
theme_gray(base_size = base_size, base_family = base_family) %+replace%
theme(
plot.title = element_text(
color = couleurs_inrae["vert_inrae_fonce"],
family = "Raleway",
face = "bold",
size = rel(1.2),
hjust = 0,
vjust = 1
),
plot.subtitle = element_text(
color = couleurs_inrae["vert_inrae"],
family = "Avenir Next Pro",
# face = 'bold',
size = rel(0.8),
hjust = 0,
vjust = 1
),
plot.caption = element_text(
color = couleurs_inrae["vert_inrae"],
family = "Avenir Next Pro",
hjust = 1,
# face = 'bold',
size = rel(0.8)
),
legend.text = element_text(colour = couleurs_inrae["vert_inrae"]),
legend.title = element_text(
colour = couleurs_inrae["vert_inrae_fonce"],
face = "bold",
hjust = 0
),
legend.background = element_rect(
fill = "transparent",
colour = NA
),
legend.key = element_rect(
fill = "transparent",
colour = NA
),
axis.ticks = element_line(color = couleurs_inrae["vert_inrae_fonce"]),
axis.text = element_text(colour = couleurs_inrae["vert_inrae"]),
axis.title.x = element_text(
colour = couleurs_inrae["vert_inrae_fonce"],
hjust = 1,
face = "bold"
),
axis.title.y = element_text(
colour = couleurs_inrae["vert_inrae_fonce"],
angle = 90,
hjust = 1,
face = "bold"
),
panel.background = element_rect(
fill = couleurs_inrae["blanc"],
colour = couleurs_inrae["vert_inrae_fonce"]
),
panel.grid.minor = element_line(
colour = couleurs_inrae["vert_inrae_clair"],
linetype = "dotted"
),
panel.grid.major = element_line(
colour = couleurs_inrae["vert_inrae_clair"],
linetype = "dashed"
),
plot.background = element_rect(
fill = NA,
colour = couleurs_inrae["vert_inrae_fonce"]
)
)
}
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# InraeThemes
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
<!-- badges: end -->
InraeThemes est un package proposant une variété de templates (Rmarkdown) et de thèmes (ggplot) qui respectent la charte graphique INRAE.
**Attention : Ces modèles nécessitent l'installation de 2 polices adoptées dans la charte graphique INRAE : "Raleway" et "Avenir Next Pro".**
## Installation
Le package peut-être installé via :
``` r
# install.packages("devtools")
devtools::install_github("davidcarayon/InraeThemes")
```
## Exemple
Voici un exemple de graphique utilisant un thème ggplot INRAE :
```{r example, message = FALSE}
library(InraeThemes)
library(ggplot2)
ggplot(mtcars, aes(x=wt, y=mpg)) +
geom_point(aes(color = as.factor(gear)))+
scale_color_inrae_n5()+
geom_smooth(color = couleurs_inrae[1]) +
labs(x = "Valeur de X", y = "Valeur de Y", title = "Titre du graphique", subtitle = "Sous-titre", color = "couleur") +
theme_inrae()
```
## Utilisation de modèles
Ce package permet de rédiger des rapports pré-formatés au style INRAE. Le modèle est directement accessible dans Rstudio via `File > New File > Rmarkdown > From Template`.
<!-- README.md is generated from README.Rmd. Please edit that file -->
# InraeThemes
<!-- badges: start -->
[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
<!-- badges: end -->
InraeThemes est un package proposant une variété de templates
(Rmarkdown) et de thèmes (ggplot) qui respectent la charte graphique
INRAE.
**Attention : Ces modèles nécessitent l’installation de 2 polices
adoptées dans la charte graphique INRAE : “Raleway” et “Avenir Next
Pro”.**
## Installation
Le package peut-être installé via :
``` r
# install.packages("devtools")
devtools::install_github("davidcarayon/InraeThemes")
```
## Exemple
Voici un exemple de graphique utilisant un thème ggplot INRAE :
``` r
library(InraeThemes)
library(ggplot2)
ggplot(mtcars, aes(x=wt, y=mpg)) +
geom_point(aes(color = as.factor(gear)))+
scale_color_inrae_n5()+
geom_smooth(color = couleurs_inrae[1]) +
labs(x = "Valeur de X", y = "Valeur de Y", title = "Titre du graphique", subtitle = "Sous-titre", color = "couleur") +
theme_inrae()
```
<img src="man/figures/README-example-1.png" width="100%" />
## Utilisation de modèles
Ce package permet de rédiger des rapports pré-formatés au style INRAE.
Le modèle est directement accessible dans Rstudio via `File > New File >
Rmarkdown > From Template`.
---
title: "Titre du document"
subtitle: "Sous-titre du document"
author: "Auteur du document"
date: "`r format(Sys.Date(), '%d %B %Y')`"
output:
pagedown::html_paged:
highlight: haddock
toc: true
lot: true
lof: true
css:
- "style/inrae.css"
knit: pagedown::chrome_print
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = FALSE,
message = FALSE,
warning = FALSE,
dpi = 300,
out.width = 2100
)
```
```{r packages}
library(InraeThemes)
library(dplyr)
library(ggplot2)
library(gt)
```
```{r}
# Si besoin des couleurs
couleurs_inrae<-rgb(red=c(102,0,39,0,255,157,158,66,121,196),
green=c(193,140,86,0,255,197,214,48,120,192),
blue=c(191,86,98,0,255,68,227,137,112,179),
names=c("vert_inrae_clair","vert_inrae","vert_inrae_fonce","noir","blanc","vert","bleu_clair","bleu_fonce","gris_fonce","gris_clair"),
max= 255)
```
>
> # RESUME
>
> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
>
# Premier chapitre
## Première section
### Une sous-section
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
## Seconde section
Ci-dessous un graphique avec theme INRAE :
```{r plot}
ggplot(mtcars, aes(x=wt, y=mpg)) +
geom_point(aes(color = as.factor(gear)))+
scale_color_inrae_n5()+
geom_smooth(color = couleurs_inrae[1]) +
labs(x = "Valeur de X", y = "Valeur de Y", title = "Titre du graphique", subtitle = "Sous-titre", color = "couleur") +
theme_inrae()
```
# Second chapitre
## Première section
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
```{r gt}
iris %>%
head(10) %>%
gt()
```
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
## Seconde section
Avec insertion de code :
```{r echo = TRUE}
# On charge un package
library(ggplot2)
# On trace un graphique ggplot avec un second theme INRAE
ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
geom_boxplot(color = "black") +
geom_jitter(shape = 21, color = "black", alpha = 0.6)+
labs(x = "Species", y = "Sepal Length") +
theme_inrae_1()
```
/* DISCLAIMER : Ce travail s'appuie sur le template bénévolement produit par T. Vroylandt pour les scouts de france et mis à disposition de la communauté (tvroylandt/sgdf_pagedown)
/* Code adapté par D. Carayon (INRAE)
/* paragaphe et liste */
p, ul {
color: #000000;
font-family: "Raleway";
text-align: justify;
}
/* titres */
h1, h2, h3, h4 {
color: #00a3a6;
font-family: "Raleway";
font-weight: bold;
}
/* tableaux - avec gt */
/* titres */
th {
background-color: #00a3a6 !important;
color: #FFFFFF !important;
font-family: "Raleway" !important;
font-weight: bold !important;
}
/* colonnes de group */
.gt_group_heading {
color: #00a3a6 !important;
font-family: "Raleway" !important;
font-weight: bold !important;
}
/* contenu */
td {
color: #000000;
font-family: "Raleway";
}
/* eviter les tableaux multipages */
.gt_table{
break-inside: avoid;
}
/* numerotation pages */
.pagedjs_margin-content{
color: #275662;
font-family: "Raleway";
font-weight: bold;
}
/* ---------------------- */
/* pour l'affichage web - debug*/
/* on def les variables */
:root {
--background: whitesmoke;
--pagedjs-width: 210mm;
--pagedjs-height: 297mm;
--color-paper: white;
--color-mbox: rgba(0, 0, 0, 0.2);
--running-title-width: 2.5in;
--screen-pages-spacing: 5mm;
}
/* two pages in a row if possible on screen */
@media screen {
body {
background-color: var(--background);
margin: var(--screen-pages-spacing) auto 0 auto;
}
.pagedjs_pages {
display: flex;
max-width: calc(var(--pagedjs-width) * 2);
flex: 0;
flex-wrap: wrap;
margin: 0 auto;
}
.pagedjs_page {
background-color: var(--color-paper);
box-shadow: 0 0 0 1px var(--color-mbox);
flex-shrink: 0;
flex-grow: 0;
margin: auto auto var(--screen-pages-spacing) auto;
}
}
/* when a row can hold two pages, start first p