data <- read.csv("~/Desktop/Data/heart.csv")

Simple bar plot

#Frequencies of chest pain type 
CPT_table<-table(data$ChestPainType)
CPT_table
## 
## ASY ATA NAP  TA 
## 496 173 203  46
my_bar<-barplot(CPT_table,main = "Chest pain type",
                xlab = "Frequncy of chest pain type",
                col = c("#9999FF","#FFCCCC","#99FFFF","#9999CC"))
#bar plot with number of observation 
text(my_bar,CPT_table,paste("n :",CPT_table,sep = ""),cex = 1)

Stacked bar plot

#cross tabulation of sex and chest pain type
sex_by_CPT<-table(data$Sex,data$ChestPainType)
sex_by_CPT
##    
##     ASY ATA NAP  TA
##   F  70  60  53  10
##   M 426 113 150  36
my_bar1<-barplot(sex_by_CPT,main = "sex by chest pain type",
                 xlab = "number of chest pain type",
                 col=c("#9999FF","#3366CC"),
                 legend=rownames(sex_by_CPT))

Grouped bar plot

#cross tabulation of sex and chest pain type
sex_by_CPT<-table(data$Sex,data$ChestPainType)
sex_by_CPT
##    
##     ASY ATA NAP  TA
##   F  70  60  53  10
##   M 426 113 150  36
my_bar1<-barplot(sex_by_CPT,main = "sex by chest pain type",
                 xlab = "number of chest pain type",
                 col=c("#9999FF","#3366CC"),
                 legend=rownames(sex_by_CPT),beside = T)