As I was asked to provide an example of the plotly issue, here is the code I use. Both graphs in the section "D.Notes" do not appear on the final document.
It gets worse if I replace the Text blocs with actual text.
Please let me know if I can make it any easier for it to be a reproducible example.
Thanks for all your insights
---
title: "test file for stackoverflow"
author: "Julien Kalamon"
date: "`r Sys.Date()`"
output:
rmdformats::readthedown:
highlight: kate
css : style.css
---
{r setup, include=FALSE}
## Global options
knitr::opts_chunk$set(cache = TRUE, echo=FALSE)
library(ggplot2)
library(esquisse)
library(readxl)
library(dplyr)
library(plotly)
library(knitr)
library(htmltools)
library(IRdisplay)
assur <- read_excel("C:/Users/LENOVO/Downloads/Benchmark appli assurance.xlsx")
<style>
p {
font-size: 16px;
line-height: 24px;
margin: 0px 0px 12px 0px;
}
h1, h2, h3, h4, h5, h6, legend {
font-family: Arial, sans-serif;
font-weight: 700;
color: #1A658F;
}
body {
text-align: justify;
}
</style>
# 1. Présentation de l'étude
## 1.1 Motivation & Objectifs
### A. Constats de départ
Text
### B. Objectifs
Text
### C. Hypothèses de départ
Text
## 1.2 Périmètre & Définitions
### A. Définitions
Text
### Périmètre d'étude
Text
{r, echo = FALSE}
library(rmarkdown)
paged_table(assur)
assur$`Téléchargements (en k)` <- factor(assur$`Téléchargements (en k)`, levels = c("5-10","10-50","50-100","100-500","500-1000","5000-10000"))
# 2. Phénomènes observés
## 2.1 Présentation du groupe d'étude
{r aldo, echo=FALSE}
ggplot(assur) +
aes(x = Type) +
geom_bar(fill = "#1A658F") +
labs(
y = "Total",
title = "Répartition du groupe test par type de structure"
) +
theme_minimal() -> d
ggplotly(d)
text
### A. Applications
{r adio, echo=FALSE}
ggplot(assur) +
aes(x = Applications, fill = Type) +
geom_histogram(bins = 5L) +
scale_fill_hue(direction = 1) +
labs(x = "Nombre d'applications", y = "Total", title = "Nombre d'apllications clients par assureur",
fill = "Type d'assureur") +
theme_minimal() -> p1
ggplotly(p1) ->p1
p1
Text
### B. Chiffre d'affaires
{r ada, echo=FALSE}
ggplot(assur) +
aes(x = "", y = `Chiffre d'affaire (en M\200)`) +
geom_boxplot(fill = "#1A658F") +
labs(x = "groupe test",
title = "Répartition des chiffres d'affaires dans le groupe test") +
theme_minimal() -> p3
ggplotly(p3)
Text
{r pressure, echo=FALSE}
assur %>%
filter(Type %in% c("Généraliste", "Prévoyance")) %>%
ggplot() +
aes(x = Type, y = `Chiffre d'affaire (en M\200)`, fill = Type) +
geom_boxplot() +
scale_fill_hue(direction = 1) +
labs(x = "Type d'assureur", title = "Répartition des chiffres d'affaires") +
theme_minimal() +
theme(legend.position = "none")->p5
ggplotly(p5)
Text
###
{r pressure2, echo=FALSE}
assur %>%
filter(Type %in% c("Startup", "Courtier")) %>%
ggplot() +
aes(x = Type, y = `Chiffre d'affaire (en M\200)`, fill = Type) +
geom_boxplot() +
scale_fill_viridis_d(option = "viridis",
direction = 1) +
labs(x = "Type d'assureur", title = "Répartition des chiffres d'affaires") +
theme_minimal() +
theme(legend.position = "none") -> p4
ggplotly(p4)
Text
### C. Téléchargements
{r}
results_dir <- 'results'
if(!dir.exists(results_dir)) dir.create(results_dir)
ggplot(assur) +
aes(x = `Téléchargements (en k)`) +
geom_bar(fill = "#1A658F") +
labs(y = "Total", title = "Nombre de téléchargements des applications du groupe test") +
theme_minimal() -> dark
ggplotly(dark)
Text
### D. Notes
{r}
ggplot(assur) +
aes(x = "", y = `Note moyenne`) +
geom_boxplot(fill = "#185F87") +
labs(x = "Groupe test",
title = "Répartition des notes dans le groupe test") +
theme_minimal() -> deli
ggplotly(deli)
Text
{r}
assur %>%
filter(!(Type %in% "Auto")) %>%
ggplot() +
aes(x = Type, y = `Note moyenne`, fill = Type) +
geom_boxplot() +
scale_fill_hue(direction = 1) +
labs(x = "Type d'assureur", title = "Répartition des notes par type d'assureur") +
theme_minimal() +
theme(legend.position = "none") -> BOOKER
ggplotly(BOOKER)
Text
## 2.2 Principales observations
### A. Notes & Chiffre d'affaires
{r}
ggplot(assur) +
aes(
x = `Chiffre d'affaire (en M\200)`,
y = `Note moyenne`,
colour = Type,
label = Assureur
) +
geom_jitter(shape = "circle", size = 2) +
scale_color_hue(direction = 1) +
labs(
title = "Note moyenne en fonction du chiffre d'affaire de l'assureur"
) +
theme_minimal()-> Ayton
ggplotly(Ayton)
Text
{r, echo=FALSE, warning=FALSE}
library(car)
scatterplot(`Note moyenne`~`Chiffre d'affaire (en M\200)`, data=assur)
Text
### B. Notes & Nombre d'applications
{r, echo=FALSE, warning=FALSE}
ggplot(assur) +
aes(x = Applications, y = `Note moyenne`, colour = Type, label = Assureur) +
geom_point(shape = "circle", size = 2L) +
scale_color_viridis_d(option = "viridis", direction = 1) +
labs(
title = "Nombre d'applications utilisateurs & note moyenne"
) +
theme_minimal()-> blop
ggplotly(blop)
Text
{r,warning=FALSE}
as.character(assur$Applications)->assur$Applications
ggplot(assur) +
aes(
x = Applications,
y = `Note moyenne`,
fill = Applications
) +
geom_boxplot() +
scale_fill_brewer(palette = "Set1", direction = 1) +
labs(
title = "Répartition des notes par nombre d'applications"
) +
theme_minimal() +
theme(legend.position = "none") -> GME
ggplotly(GME)
text