Untitled

mail@pastecode.io avatar
unknown
julia
2 months ago
642 B
1
Indexable
Never
# R code for creating a bar chart with error bars
library(ggplot2)
library(dplyr)

# Calculate mean and standard error of GPA for each group
summary_data <- data %>%
  group_by(Athlete) %>%
  summarise(mean_GPA = mean(GPA),
            se_GPA = sd(GPA) / sqrt(n()))

# Plot bar chart with error bars
ggplot(summary_data, aes(x = Athlete, y = mean_GPA, fill = Athlete)) +
  geom_bar(stat = "identity", position = "dodge") +
  geom_errorbar(aes(ymin = mean_GPA - se_GPA, ymax = mean_GPA + se_GPA), 
                width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Athlete Status", y = "Mean GPA", title = "Mean GPA by Athlete Status")
Leave a Comment