data <- read.csv("~/Desktop/Data/heart.csv")
my_table<-table(data$Sex)
pie(my_table, labels = paste(names (my_table),"\n", my_table,
sep =""), main = "pie chart",
col = c("#9999CC", "#FFCCFF"))
legend("topright",c("Female","male"), cex = 0.9,
fill =c("#9999CC","#FFCCFF"))
add percentages to pie chart
pie_percent<-paste0(round(100*prop.table(my_table),2), "%")
pie(my_table, labels = pie_percent, main = "pie chart",
col =c("#9999CC","#FFCCFF"))
legend("topright", c("Female","male"), cex = 0.9,
fill =c("#9999CC","#FFCCFF"))