Load libraries

library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyr)

Load data

Demographics

df <- data %>%
  select(Condition, Køn) %>%
  mutate(Køn = factor(Køn, levels = c("Male", "Female")))
# Create a histogram (or rather a bar plot, since Køn is categorical)
p <- ggplot(df, aes(x = Køn,fill = Condition)) +
  geom_bar(position = "dodge") +
  labs(title = "Gender by Condition (AI initiated vs User initiated)", x = "Gender", y = "Antal") +
  scale_fill_manual(values = c(
  "AI" = "steelblue",
  "User" = "tomato")) +
  theme_minimal()
# Show plot
p

# Save plot
ggsave(filename = paste0("plots/","Questionnaire_Gender",".png"), plot = p, width = 10, height = 6, dpi = 300, bg = "white")



df <- data %>%
  select(Condition, Alder) %>%
  mutate(Alder = factor(Alder, levels = c("21-25","26-30")))
# Create a histogram (or rather a bar plot, since Age is categorical)
p <- ggplot(df, aes(x = Alder,fill = Condition)) +
  geom_bar(position = "dodge") +
  labs(title = "Age by Condition (AI initiated vs User initiated)", x = "Age", y = "Antal") +
  scale_fill_manual(values = c(
  "AI" = "steelblue",
  "User" = "tomato")) +
  theme_minimal()
# Show plot
p

ggsave(filename = paste0("plots/","Questionnaire_Age",".png"), plot = p, width = 10, height = 6, dpi = 300, bg = "white")
# Load your data
data <- read.csv("./data/AI_usage_data.csv", dec = ",")
## Warning in read.table(file = file, header = header, sep = sep, quote = quote, :
## incomplete final line found by readTableHeader on './data/AI_usage_data.csv'
data
##      X ChatGPT Google.Gemini Siri Microsoft.Copilot GitHub.Copilot GrammalyGO
## 1   AI       9             0    2                 1              2          0
## 2 User       8             3    0                 2              1          0
##   CanvaAI I.do.not.use.AI Other
## 1       1               0     3
## 2       0               0     2
# Define your labels
my.labels <- c(
  "ChatGPT",    "Google Gemini",    "Siri", "Microsoft Copilot",    "GitHub Copilot",   "GrammalyGO",   "CanvaAI",  "I do not use AI",  "Other"
)
# Manually create the dataframe
df <- tibble::tibble(
  Group = c("AI", "User"),
  ChatGPT = c(9, 8),
  Google_Gemini = c(0, 3),
  Siri = c(2, 0),
  Microsoft_Copilot = c(1, 2),
  GitHub_Copilot = c(2, 1),
  GrammarlyGO = c(0, 0),
  CanvaAI = c(1, 0)
)

# Pivot longer for ggplot
df_long <- df %>%
  pivot_longer(cols = -Group, names_to = "Tool", values_to = "Count")

# Reorder Tool levels based on total count (descending)
df_long <- df_long %>%
  group_by(Tool) %>%
  mutate(TotalCount = sum(Count)) %>%
  ungroup() %>%
  mutate(Tool = reorder(Tool, -TotalCount))
df_long
## # A tibble: 14 × 4
##    Group Tool              Count TotalCount
##    <chr> <fct>             <dbl>      <dbl>
##  1 AI    ChatGPT               9         17
##  2 AI    Google_Gemini         0          3
##  3 AI    Siri                  2          2
##  4 AI    Microsoft_Copilot     1          3
##  5 AI    GitHub_Copilot        2          3
##  6 AI    GrammarlyGO           0          0
##  7 AI    CanvaAI               1          1
##  8 User  ChatGPT               8         17
##  9 User  Google_Gemini         3          3
## 10 User  Siri                  0          2
## 11 User  Microsoft_Copilot     2          3
## 12 User  GitHub_Copilot        1          3
## 13 User  GrammarlyGO           0          0
## 14 User  CanvaAI               0          1
# Plot
p <- ggplot(df_long, aes(x = Tool, y = Count, fill = Group)) +
  geom_bar(stat = "identity", position = position_dodge(width = 0.8), width=0.8) +
  labs(title = "AI Tools Usage by Group", x = "Tool", y = "Count") +
  theme_minimal() +
  scale_y_continuous(breaks = seq(0, 10, 1)) +
  scale_fill_manual(values = c(
  "AI" = "steelblue",
  "User" = "tomato")) +
  theme(
    axis.text.x = element_text(angle = 45, hjust = 1),
    legend.position = "top",
    panel.grid.major = element_line(color = "grey80"),
    panel.grid.minor = element_line(color = "grey90")
  )
# Save the plot
ggsave(filename = "plots/Questionnaire_AI_usage_by_group.png", plot = p, width = 10, height = 6, dpi = 300, bg = "white")

# Show plot
p

Questionnaire

library(ggplot2)
library(dplyr)
library(tidyr)

Questionnaire_plot <- function(data, questions, columns, title, title_offset) {
  
  # Prepare the data
  Engagement <- data %>%
    select(Condition, all_of(columns)) %>%
    mutate(Condition = factor(Condition, levels = c("AI", "User"))) %>%
    mutate(across(2:ncol(.), as.numeric))
  
  # Pivot longer
  Engagement_long <- Engagement %>%
    pivot_longer(cols = -Condition, 
                 names_to = "Question", 
                 values_to = "Score") %>%
    mutate(Question = factor(Question, levels = unique(Question)))
  
  # Plot
  p <- ggplot(Engagement_long, aes(x = Question, y = Score, fill = Condition)) +
    stat_summary(fun = mean, geom = "bar", position = position_dodge()) +
    labs(title = title, 
         x = "", y = "Average Score") +
    stat_summary(fun = mean, 
                 geom = "text", 
                 aes(label = round(..y.., 2)),  
                 position = position_dodge(width = 0.9), 
                 vjust = 0.4, hjust = 1.2, size = 3.5) +
    scale_x_discrete(labels = questions) +
    scale_fill_manual(values = c(
                  "AI" = "steelblue",
                  "User" = "tomato")) +
    theme_minimal() +
    theme(legend.position = "top",panel.grid.minor = element_line(color = "grey78")) + 
    coord_flip()
  
  # Save plot
  ggsave(filename = paste0("plots/","Questionnaire_",title, ".png"), plot = p, width = 10, height = 6, dpi = 300, bg = "white")
  
  # Return plot
  return(p)
}
# Load your data
data <- read.csv("./data/Questionnaire_data.csv", dec = ",")

# Define your labels
my.labels <- c(
  "I hvilken grad følte du dig mentalt fordybet i oplevelsen? \n(1 = Slet ikke, 7 Rigtig meget)",  
  "Hvor involverende var oplevelsen? \n(1 = Slet ikke, 7 Rigtig meget)",  
  "Hvor fuldstændigt blev dine sanser engageret? \n(1 = Slet ikke, 7 Rigtig meget)",  
  "I hvilken grad oplevede du en følelse af virkelighed?\n(1 = Slet ikke, 7 Rigtig meget)",  
  "Hvor engagerende var samtalen? \n(1 = Slet ikke, 7 Rigtig meget)",  
  "Hvor afslappende eller spændende var oplevelsen? \n(1 = Meget afslappende, 7 Meget spændende)"
)

# Call the function
Questionnaire_plot(data, questions = my.labels, columns = 6:11, title = "Average Engagement per question by Condition",title_offset=0)
## Warning: The dot-dot notation (`..y..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(y)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

# Load your data
data <- read.csv("./data/Questionnaire_data.csv", dec = ",")

# Define your labels
my.labels <- c(
  "Brugen af ROSIE i mit projekt \nville gøre mig i stand til at udføre opgaver hurtigere \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)",  
  "Brugen af ROSIE ville kunne forbedre min arbejdspræstation \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)",  
  "Brugen af ROSIE i mit arbejde ville øge min produktivitet. \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)",  
  "Brugen af ROSIE ville forbedre min evne til at udføre \nmit arbejde godt. \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)",  
  "Brugen af ROSIE ville gøre det \nlettere at udføre mit arbejde. \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)",  
  "Jeg synes at ROSIE ville være nyttig i mit arbejde. \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)"
)

# Call the function
Questionnaire_plot(data, questions = my.labels, columns = 6:11, title = "Perceived usefulness per question by Condition",title_offset=0)

# Load your data
data <- read.csv("./data/Questionnaire_data.csv", dec = ",")

# Define your labels
my.labels <- c(
  "Det ville være nemt for mig at lære at betjene ROSIE \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)",  
  "Jeg ville have nemt ved at få ROSIE \ntil at gøre hvad jeg ville have hende til at gøre \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)",  
  "Min interaktion med ROSIE ville være tydelig og forståelig \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)",  
  "Jeg kunne forestille mig, at ROSIE ville være tydelig og forståelig \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)",  
  "Det ville være nemt for mig at blive dygtig til at bruge ROSIE \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)",  
  "Jeg kunne forestille mig, at ROSIE ville være nem at bruge \n(1 = Meget usandsynligt, 7 = Meget sandsynligt)"
)

# Call the function
Questionnaire_plot(data, questions = my.labels, columns = 6:11, title = " Perceived Ease of Use (PEU) per question by Condition",title_offset=-0.6)

# Load your data
data <- read.csv("./data/Questionnaire_data.csv", dec = ",")

Intention_To_use_data <- data %>%
  select(Condition, 27) %>%
  mutate(Condition = factor(Condition, levels = c("AI", "User"))) %>%
  mutate(across(2:ncol(.), as.numeric))

# Pivot longer
Intention_To_use_data_long <- Intention_To_use_data %>%
  pivot_longer(cols = -Condition, 
               names_to = "Question", 
               values_to = "Score") %>%
  mutate(Question = factor(Question, levels = unique(Question)))
Intention_To_use_data_long
## # A tibble: 18 × 3
##    Condition Question               Score
##    <fct>     <fct>                  <dbl>
##  1 AI        Intention.of.use.Score  5.08
##  2 AI        Intention.of.use.Score  3.83
##  3 AI        Intention.of.use.Score  6.58
##  4 AI        Intention.of.use.Score  5.75
##  5 AI        Intention.of.use.Score  4.5 
##  6 AI        Intention.of.use.Score  5.17
##  7 AI        Intention.of.use.Score  4.83
##  8 AI        Intention.of.use.Score  5.5 
##  9 AI        Intention.of.use.Score  5.58
## 10 User      Intention.of.use.Score  4.42
## 11 User      Intention.of.use.Score  5.75
## 12 User      Intention.of.use.Score  6.25
## 13 User      Intention.of.use.Score  3.5 
## 14 User      Intention.of.use.Score  3.33
## 15 User      Intention.of.use.Score  5.75
## 16 User      Intention.of.use.Score  4.5 
## 17 User      Intention.of.use.Score  5.25
## 18 User      Intention.of.use.Score  5.25
# T-test
t_test_result <- t.test(Intention_To_use_data_long$Score ~ Intention_To_use_data_long$Condition)

IntentiontoUsewithPvalueString <- paste("Intention to use (p =", round(t_test_result$p.value, 3), ")")


Engagement_data <- data %>%
  select(Condition, 12) %>%
  mutate(Condition = factor(Condition, levels = c("AI", "User"))) %>%
  mutate(across(2:ncol(.), as.numeric))

# Pivot longer
Engagement_data_long <- Engagement_data %>%
  pivot_longer(cols = -Condition, 
               names_to = "Question", 
               values_to = "Score") %>%
  mutate(Question = factor(Question, levels = unique(Question)))
Engagement_data_long
## # A tibble: 18 × 3
##    Condition Question           Score
##    <fct>     <fct>              <dbl>
##  1 AI        Score...Engagement  4.83
##  2 AI        Score...Engagement  3.33
##  3 AI        Score...Engagement  4.5 
##  4 AI        Score...Engagement  5.5 
##  5 AI        Score...Engagement  3.67
##  6 AI        Score...Engagement  4.83
##  7 AI        Score...Engagement  3.67
##  8 AI        Score...Engagement  3.83
##  9 AI        Score...Engagement  4.33
## 10 User      Score...Engagement  4.33
## 11 User      Score...Engagement  4.5 
## 12 User      Score...Engagement  4.33
## 13 User      Score...Engagement  4.33
## 14 User      Score...Engagement  2.83
## 15 User      Score...Engagement  4.5 
## 16 User      Score...Engagement  3.67
## 17 User      Score...Engagement  3.83
## 18 User      Score...Engagement  2.83
# T-test
t_test_result <- t.test(Engagement_data_long$Score ~ Engagement_data_long$Condition)

EngagementwithPvalueString <- paste("Engagement (p =", round(t_test_result$p.value, 3), ")")



# Define your labels
my.labels <- c(
  EngagementwithPvalueString,  
  "Percieved usefulness",  
  "Perceived Ease of Use (PEU)",
  IntentiontoUsewithPvalueString
  
)
# Call the function
Questionnaire_plot(data, questions = my.labels, columns = c(12,19,26,27), title = "Scores for each construct",title_offset = 0.4)