library(readr)
motivation <- read_csv("~/Downloads/motivation.csv")
## Rows: 14 Columns: 30
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (6): Gender, Afdeling_coschap, Previous_Ed, Failed, relevance_coschap, ...
## dbl (24): User_ID, Intrinsic Motivation_Med, Identified Regulation_Med, Intr...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
library(readr)
motivatie <- read_csv("~/Downloads/motivatie.csv")
## Rows: 14 Columns: 30
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (6): Gender, Afdeling_coschap, Previous_Ed, Failed, relevance_coschap, ...
## dbl (24): User_ID, Intrinsic Motivation_Med, Identified Regulation_Med, Intr...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
motivation_eng<-na.omit(motivatie)
library(ggplot2)

ggplot(motivation, aes(x = RAM_Med, y = RAM_KNO, color = as.factor(row.names(motivation)))) +
  geom_point(size = 5) +
  geom_vline(xintercept = 0, color = "#A9A9A9") +  # Add vertical line at x = 0
  geom_hline(yintercept = 0, color = "#A9A9A9") +  # Add horizontal line at y = 0
  scale_color_discrete() +
  labs(title = "RAM Medicine vs RAM KNO",
       x = "RAM Medicine",
       y = "RAM KNO") +
  xlim(-3, 15) + 
  ylim(-3, 15) +  
  theme_minimal() +
  theme(legend.position = "none")
## Warning: Removed 6 rows containing missing values or values outside the scale range
## (`geom_point()`).

library(ggplot2)
library(gridExtra)

# Convert 'relevance_coschap' to factor
motivation$relevance_coschap <- as.factor(motivation$relevance_coschap)

# Box plot for AM_KNO with scatter plot overlay
p1 <- ggplot(data = motivation, aes(x = relevance_coschap, y = AM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = Gender, shape = Gender), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Internship \non AM_KNO",
    x = "Relevance Internship",
    y = "Autonomous Motivation for KNO"
  ) +
  scale_color_manual(values = c("vrouw" = "lightpink", "man" = "lightblue")) +  # Set colors for Gender
  scale_shape_manual(values = c("vrouw" = 16, "man" = 15)) +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Box plot for CM_KNO with scatter plot overlay
p2 <- ggplot(data = motivation, aes(x = relevance_coschap, y = CM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = Gender, shape = Gender), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Internship \non CM_KNO",
    x = "Relevance Internship",
    y = "Controlled Motivation for KNO"
  ) +
  scale_color_manual(values = c("vrouw" = "lightpink", "man" = "lightblue")) +  # Set colors for Gender
  scale_shape_manual(values = c("vrouw" = 16, "man" = 15)) +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Display plots side by side
grid.arrange(p1, p2, ncol = 2)

p3 <- ggplot(data = motivation, aes(x = relevance_career, y = AM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = Gender, shape = Gender), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Career \non AM_KNO",
    x = "Relevance Career",
    y = "Autonomous Motivation for KNO"
  ) +
  scale_color_manual(values = c("vrouw" = "lightpink", "man" = "lightblue")) +  # Set colors for Gender
  scale_shape_manual(values = c("vrouw" = 16, "man" = 15)) +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Box plot for CM_KNO with scatter plot overlay
p4 <- ggplot(data = motivation, aes(x = relevance_career, y = CM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = Gender, shape = Gender), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Career \non CM_KNO",
    x = "Relevance Career",
    y = "Controlled Motivation for KNO"
  ) +
  scale_color_manual(values = c("vrouw" = "lightpink", "man" = "lightblue")) +  # Set colors for Gender
  scale_shape_manual(values = c("vrouw" = 16, "man" = 15)) +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Display plots side by side
grid.arrange(p3, p4, ncol = 2)

# Create a factor variable for User_ID
motivation$User_ID <- as.factor(seq_len(nrow(motivation)))

# Convert relevance_coschap and relevance_career to factors
motivation$relevance_coschap <- as.factor(motivation$relevance_coschap)
motivation$relevance_career <- as.factor(motivation$relevance_career)

# Box plot for AM_KNO with scatter plot overlay
p1 <- ggplot(data = motivation, aes(x = relevance_coschap, y = AM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = User_ID), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Internship \non AM_KNO",
    x = "Relevance Internship",
    y = "Autonomous Motivation for KNO"
  )  +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Box plot for CM_KNO with scatter plot overlay
p2 <- ggplot(data = motivation, aes(x = relevance_coschap, y = CM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = User_ID), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Internship \non CM_KNO",
    x = "Relevance Internship",
    y = "Controlled Motivation for KNO"
  )  +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Display plots side by side
grid.arrange(p1, p2, ncol = 2)
## Warning: Removed 6 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 6 rows containing missing values or values outside the scale range
## (`geom_point()`).
## Warning: Removed 6 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 6 rows containing missing values or values outside the scale range
## (`geom_point()`).

p3 <- ggplot(data = motivation, aes(x = relevance_career, y = AM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = User_ID), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Career \non AM_KNO",
    x = "Relevance Career",
    y = "Autonomous Motivation for KNO"
  )  +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Box plot for CM_KNO with scatter plot overlay
p4 <- ggplot(data = motivation, aes(x = relevance_career, y = CM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = User_ID), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Career \non CM_KNO",
    x = "Relevance Career",
    y = "Controlled Motivation for KNO"
  )  +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Display plots side by side
grid.arrange(p3, p4, ncol = 2)
## Warning: Removed 6 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Removed 6 rows containing missing values or values outside the scale range
## (`geom_point()`).
## Warning: Removed 6 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 6 rows containing missing values or values outside the scale range
## (`geom_point()`).

install.packages("ggbeeswarm", repos = "https://cloud.r-project.org/")
## 
## The downloaded binary packages are in
##  /var/folders/3g/ln4t2cvs3250dv7p12p13c_c0000gn/T//RtmpbIl1uG/downloaded_packages
library(ggbeeswarm)
library(ggplot2)
library(gridExtra)

motivatie$RowID <- as.factor(seq_len(nrow(motivatie)))
motivatie$relevance_coschap <- as.factor(motivatie$relevance_coschap)
motivatie$relevance_career <- as.factor(motivatie$relevance_career)

# Bee swarm plot for AM_KNO with relevance_coschap
p1 <- ggplot(data = motivatie, aes(x = AM_KNO, y = Level_Completed, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    title = "Effect of AM KNO \non Engagement",
    x = "Autonomous Motivation for KNO",
    y = "Level Completed",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))+xlim(0,7)

# Bee swarm plot for CM_KNO with relevance_coschap
p2 <- ggplot(data = motivatie, aes(x = CM_KNO, y = Level_Completed, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    title = "Effect of CM KNO \non Engagement",
    x = "Controlled Motivation for KNO",
    y = "Level Completed",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))+xlim(0,7) 

# Display plots side by side
grid.arrange(p1, p2, ncol = 2)

# Bee swarm plot for AM_KNO with relevance_career
p3 <- ggplot(data = motivatie, aes(x = AM_KNO, y = Questions_Attemped, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    title = "Effect AM KNO \non Engagement",
    x = "Autonomous Motivation for KNO",
    y = "Questions Attempted",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +xlim(0,7)

# Bee swarm plot for CM_KNO with relevance_career
p4 <- ggplot(data = motivatie, aes(x = CM_KNO, y = Questions_Attemped, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    title = "Effect of CM KNO \non Engagement",
    x = "Controlled Motivatiin for KNO",
    y = "Questions Attempted",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))+xlim(0,7) 

# Display plots side by side
grid.arrange(p3, p4, ncol = 2)

motivatie<- na.omit(motivatie)
motivatie$RowID <- as.factor(seq_len(nrow(motivatie)))
motivatie$relevance_coschap <- as.factor(motivatie$relevance_coschap)
motivatie$relevance_career <- as.factor(motivatie$relevance_career)

# Bee swarm plot for AM_KNO with relevance_coschap
p5 <- ggplot(data = motivatie, aes(x = relevance_career, y = Level_Completed, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    x = "relevance career",
    y = "Level Completed",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) 

# Bee swarm plot for CM_KNO with relevance_coschap
p6 <- ggplot(data = motivatie, aes(x = relevance_coschap, y = Level_Completed, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    x = "Relevance for Internship",
    y = "Level Comppleted",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) 

# Display plots side by side
grid.arrange(p5, p6, ncol = 2, top="Effect of relevance for KNO on Engagement")

p7 <- ggplot(data = motivatie, aes(x = relevance_career, y = Questions_Attemped, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    x = "relevance career",
    y = "Questions Attempted",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) 

p8 <- ggplot(data = motivatie, aes(x = relevance_coschap, y = Questions_Attemped, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    x = "relevance for internship",
    y = "Questions Attempted",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) 


# Display plots side by side
grid.arrange(p7, p8, ncol = 2, top="Effect of relevance for KNO on Engagement")

library(ggplot2)
library(ggbeeswarm)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:gridExtra':
## 
##     combine
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(forcats)
library(gridExtra)
motivation_eng <- na.omit(motivatie[, c("relevance_coschap", "RAM_Med", "RAM_KNO", "AM_KNO", "CM_KNO", "relevance_career","Questions_Attemped", "Level_Completed")])

# Simplify categorical variables if necessary
motivation_eng <- motivation_eng %>%
  mutate(relevance_coschap = fct_collapse(relevance_coschap,
                                          "No" = c("Niet", "Waarschijnlijk niet"),
                                          "Yes" = c("Waarschijnlijk wel", "Zeker wel")),
         relevance_career = fct_collapse(relevance_career,
                                         "No" = c("Niet", "Waarschijnlijk niet"),
                                         "Yes" = c("Waarschijnlijk wel", "Zeker wel")))
## Warning: There were 2 warnings in `mutate()`.
## The first warning was:
## ℹ In argument: `relevance_coschap = fct_collapse(...)`.
## Caused by warning:
## ! Unknown levels in `f`: Niet
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 1 remaining warning.
motivation_eng$RowID <- as.factor(seq_len(nrow(motivation_eng)))

p5 <- ggplot(data = motivation_eng, aes(x = relevance_career, y = Level_Completed, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    x = "relevance career",
    y = "Level Completed",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) 

# Bee swarm plot for CM_KNO with relevance_coschap
p6 <- ggplot(data = motivation_eng, aes(x = relevance_coschap, y = Level_Completed, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    x = "Relevance for Internship",
    y = "Level Comppleted",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) 

# Display plots side by side
grid.arrange(p5, p6, ncol = 2, top="Effect of relevance for KNO on Engagement")

p7 <- ggplot(data = motivation_eng, aes(x = relevance_career, y = Questions_Attemped, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    x = "relevance career",
    y = "Questions Attempted",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) 

p8 <- ggplot(data = motivation_eng, aes(x = relevance_coschap, y = Questions_Attemped, color = RowID)) +
  geom_quasirandom(width = 0.2) +
  labs(
    x = "relevance for internship",
    y = "Questions Attempted",
    color = "User ID"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) 


# Display plots side by side
grid.arrange(p7, p8, ncol = 2, top="Effect of relevance for KNO on Engagement")

# Create a factor variable for User_ID

motivation_eng$User_ID <- as.factor(seq_len(nrow(motivation_eng)))

# Convert relevance_coschap and relevance_career to factors
motivation_eng$relevance_coschap <- as.factor(motivation_eng$relevance_coschap)
motivation_eng$relevance_career <- as.factor(motivation_eng$relevance_career)

# Box plot for AM_KNO with scatter plot overlay
p1 <- ggplot(data = motivation_eng, aes(x = relevance_coschap, y = AM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = User_ID), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Internship \non AM_KNO",
    x = "Relevance Internship",
    y = "Autonomous Motivation for KNO"
  )  +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Box plot for CM_KNO with scatter plot overlay
p2 <- ggplot(data = motivation_eng, aes(x = relevance_coschap, y = CM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = User_ID), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Internship \non CM_KNO",
    x = "Relevance Internship",
    y = "Controlled Motivation for KNO"
  )  +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Display plots side by side
grid.arrange(p1, p2, ncol = 2)

p3 <- ggplot(data = motivation_eng, aes(x = relevance_career, y = AM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = User_ID), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Career \non AM_KNO",
    x = "Relevance Career",
    y = "Autonomous Motivation for KNO"
  )  +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Box plot for CM_KNO with scatter plot overlay
p4 <- ggplot(data = motivation_eng, aes(x = relevance_career, y = CM_KNO)) +
  geom_boxplot() +
  geom_jitter(aes(color = User_ID), width = 0.4) +  # Add scatter plot with jitter, color, and shape by Gender
  labs(
    title = "Effect of Relevance Career \non CM_KNO",
    x = "Relevance Career",
    y = "Controlled Motivation for KNO"
  )  +  # Set shapes for Gender (16 = circle, 15 = square)
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ylim(0, 7)

# Display plots side by side
grid.arrange(p3, p4, ncol = 2)