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

@@ -1,5 +1,5 @@
```{r}
setwd('/Users/arthurdanjou/Workspace/studies/M1/General Linear Models/TP2')
setwd("/Users/arthurdanjou/Workspace/studies/M1/General Linear Models/TP2")
```
# Question 1 : Import dataset and check variables
@@ -9,8 +9,8 @@ library(dplyr)
cepages <- read.csv("Cepages B TP2.csv", header = TRUE, sep = ";", dec = ",")
cepages$Couleur <- as.factor(cepages$Couleur)
cepages$Origine <- as.factor(cepages$Origine)
cepages <- cepages %>% mutate(across(where(is.character), as.numeric))
cepages <- cepages %>% mutate(across(where(is.integer), as.numeric))
cepages <- cepages |> mutate(across(where(is.character), as.numeric))
cepages <- cepages |> mutate(across(where(is.integer), as.numeric))
paged_table(cepages)
```
@@ -39,7 +39,7 @@ tapply(cepages$pH, list(cepages$Couleur, cepages$Origine), mean)
library(ggplot2)
ggplot(cepages, aes(x = AcTot, y = pH, color = Couleur)) +
geom_point(col = 'red', size = 0.5) +
geom_point(col = "red", size = 0.5) +
geom_smooth(method = "lm", se = F)
ggplot(cepages, aes(y = pH, x = AcTot, colour = Couleur, fill = Couleur)) +
@@ -50,8 +50,8 @@ ggplot(cepages, aes(y = pH, x = AcTot, colour = Couleur, fill = Couleur)) +
```{r}
ggplot(cepages, aes(x = AcTot, y = pH, color = Origine)) +
geom_smooth(method = 'lm', se = F) +
geom_point(col = 'red', size = 0.5)
geom_smooth(method = "lm", se = F) +
geom_point(col = "red", size = 0.5)
ggplot(cepages, aes(y = pH, x = AcTot, colour = Origine, fill = Origine)) +
geom_boxplot(alpha = 0.5, outlier.alpha = 0)