Refactor code for improved readability and consistency across R Markdown files

- Updated comments and code formatting in `3-td_ggplot2 - enonce.Rmd` for clarity.
- Enhanced code structure in `4-td_graphiques - enonce.Rmd` by organizing options and library calls.
- Replaced pipe operator `%>%` with `|>` in `Code_Lec3.Rmd` for consistency with modern R syntax.
- Cleaned up commented-out code and ensured consistent spacing in ggplot calls.
This commit is contained in:
2025-11-06 09:26:58 +01:00
parent 8f5f2b417c
commit 03bf0a4db2
10 changed files with 764 additions and 588 deletions

View File

@@ -297,7 +297,7 @@ On présente ci-dessous un aperçu des données.
fold <- getwd()
# Load data
# load(paste0(fold, "/M2/Data Visualisation/tp1", "/data/datafreMPTL.RData")) # VSCode # nolint
# load(paste0(fold, "/M2/Data Visualisation/tp1", "/data/datafreMPTL.RData")) # VSCode
load(paste0(fold, "/data/datafreMPTL.RData")) # RStudio
paged_table(dat, options = list(rows.print = 15))
```
@@ -505,7 +505,7 @@ df_plot <- dat |>
p3 <- ggplot(df_plot, aes(x = DrivAge, y = freq)) +
geom_point() +
geom_smooth() +
labs(x = "Age du conducteur", y = "Frequence") +
labs(x = "Age du conducteur", y = "Frequence") +
theme_bw()
p3
```
@@ -642,12 +642,16 @@ plot_pairwise_disc <- function(df, var1, var2) {
df |>
group_by(varx, vary) |>
summarize(exp = sum(Exposure),
nb_claims = sum(ClaimNb),
freq = sum(ClaimNb) / sum(Exposure), .groups = "drop") |>
summarize(
exp = sum(Exposure),
nb_claims = sum(ClaimNb),
freq = sum(ClaimNb) / sum(Exposure), .groups = "drop"
) |>
ggplot(aes(x = varx, y = freq, colour = vary, group = vary), alpha = 0.3) +
geom_point() + geom_line() + theme_bw() +
labs(x = var1, y = "Frequence", colour = var2)
geom_point() +
geom_line() +
theme_bw() +
labs(x = var1, y = "Frequence", colour = var2)
}
```