Here is one with base R. Get the count of 'Yes' with rowSums on a logical matrix selecting only the 'Var' columns, then do a group by 'Sex' to summarise the count by Sex with rowsum) and use barplot
barplot(t(rowsum(rowSums(df1[-1] == 'Yes'), df1$Sex)))
Or if we need a group by barplot, change it to
barplot(t(rowsum(+(df1[-1] == 'Yes'), df1$Sex)), beside = TRUE,
legend = TRUE, col = c('red', 'blue', 'green'))
Or if we prefer ggplot, reshape to 'long' format with pivot_longer (from tidyr), get a group_by, summarise to return the count of 'Yes' and use ggplot
library(dplyr)
library(tidyr)
library(ggplot2)
df1 %>%
pivot_longer(cols = -Sex) %>%
group_by(Sex) %>%
summarise(n = sum(value == 'Yes')) %>%
ggplot(aes(x = Sex, y = n)) +
geom_col()
For a bar for each 'Var'
df1 %>%
pivot_longer(cols = -Sex) %>%
group_by(Sex, name) %>%
summarise(n = sum(value == 'Yes'), .groups = 'drop') %>%
ggplot(aes(x = Sex, y = n, fill = name)) +
geom_col(position = 'dodge')
-output

data
df1 <- structure(list(Sex = c("Male", "Female", "Male", "Female"),
Var1 = c("Yes",
"No", "No", "Yes"), Var2 = c("No", "Yes", "No", "Yes"), Var3 = c("Yes",
"No", "Yes", "No")), class = "data.frame", row.names = c(NA,
-4L))