'How can I add multiple data to a geom_bar

I'm new to R and I wanna add multiple values to geom_bar. I'm getting these values from a csv file and adding it to dataset and from there I wanna add it to the plot. This is my code so far:

library(ggplot2)

Passed_Students<- read.csv("C:/Users/kemal/Documents/OOP_eindopdracht/Eindopdracht_3/Processed_csv_file/Behaalde_studenten.csv")
Fast_students<- read.csv("C:/Users/kemal/Documents/OOP_eindopdracht/Eindopdracht_3/Processed_csv_file/Snelle_studenten.csv")
#rm(Behaalde_studenten)
#rm(Snelle_studenten)
#print(Behaalde_studenten)

ggplot(Passed_Students, aes(x="Passed_Students", y="Aantal")) + 
  geom_bar(stat = "identity", width = 0.3) +
  

I want it so that Passed_Students and Fast_student are next to each other in the geom_bar. my Passed_student and fast_student looks like this:

  X1
1|23
2|34
3|36
4|72
5|100

they both look something like this only difference is that one is smaller then the other!

It should look something like this



Solution 1:[1]

Try this:

How I created the data: using tribble function from tibble package (it is in tidyverse):

  
df <- tribble(
  ~N, ~Students,
  23, "Passed",
  34, "Fast",
  36, "Passed",
  72, "Fast",
  100, "Passed"
)
library(ggplot2)

ggplot(df, aes(x=Students, y=N, fill=Students))+
  geom_bar(position="dodge", stat="identity", width=0.3)

enter image description here

data:

df <- structure(list(N = c(23, 34, 36, 72, 100), Students = c("Passed", 
"Fast", "Passed", "Fast", "Passed")), class = c("tbl_df", "tbl", 
"data.frame"), row.names = c(NA, -5L))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1