Loaded the data as csv.

rejected<-read.csv("https://raw.githubusercontent.com/Sangeetha-007/R-Practice/master/607/Projects/Project%202/Admitted_Rejected%20-%20Sheet1.csv")
rejected
##    Gender Dept Admitted Rejected
## 1    Male    A      512      313
## 2  Female    A       89       19
## 3    Male    B      353      207
## 4  Female    B       17        8
## 5    Male    C      120      205
## 6  Female    C      202      391
## 7    Male    D      138      279
## 8  Female    D      131      244
## 9    Male    E       53      138
## 10 Female    E       94      299
## 11   Male    F       22      351
## 12 Female    F       24      317

I used the sapply function to know what data types each column are.

sapply(rejected, class)
##      Gender        Dept    Admitted    Rejected 
## "character" "character"   "integer"   "integer"

I pivoted longer the Admitted & Rejected columns into Count.

new_df <- rejected |> pivot_longer(cols=c("Admitted", "Rejected"), names_to="Status",
               values_to="Count") 
new_df
## # A tibble: 24 × 4
##    Gender Dept  Status   Count
##    <chr>  <chr> <chr>    <int>
##  1 Male   A     Admitted   512
##  2 Male   A     Rejected   313
##  3 Female A     Admitted    89
##  4 Female A     Rejected    19
##  5 Male   B     Admitted   353
##  6 Male   B     Rejected   207
##  7 Female B     Admitted    17
##  8 Female B     Rejected     8
##  9 Male   C     Admitted   120
## 10 Male   C     Rejected   205
## # … with 14 more rows

I grouped the dataframe by Gender and Status, then summarized the count.

dfForGraph<- new_df %>% group_by(Gender, Status) %>% summarize(Sum = sum(Count))
dfForGraph
## # A tibble: 4 × 3
## # Groups:   Gender [2]
##   Gender Status     Sum
##   <chr>  <chr>    <int>
## 1 Female Admitted   557
## 2 Female Rejected  1278
## 3 Male   Admitted  1198
## 4 Male   Rejected  1493

Finally, I made a bar graph divided by their Status (Admitted/Rejected) based on their Gender.

ggplot(dfForGraph, aes( y=`Sum`, x=Gender)) + 
    geom_bar(position="dodge", stat="identity")+facet_wrap(~Status)

Source: https://r-graph-gallery.com/48-grouped-barplot-with-ggplot2