library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.1 ✔ purrr 1.0.1
✔ tibble 3.1.8 ✔ dplyr 1.1.0
✔ tidyr 1.3.0 ✔ stringr 1.5.0
✔ readr 2.1.4 ✔ forcats 1.0.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
<- c(2.5, 8, 4)
grades <- c("A","B","C")
students <- tibble(students,grades)
student_performance
# alternate syntax
<- tibble(
student_performance grades = c(2.5, 8, 4),
students = c("A","B","C")
)
# ggplot bar graph
ggplot(student_performance, aes(x = students, y = grades))+
geom_bar(stat = "identity", fill = "white", color = "blue") +
scale_y_continuous(breaks = 0:10,limits = c(0,10)) +
theme_classic() +
geom_text(label=grades, position = position_dodge(width=.9), vjust=-0.4)+
xlab("Students")+
ylab("Grades") +
ggtitle("Student Performance") +
theme_classic(base_size = 12) +
theme(plot.title = element_text(hjust = 0.5))