You are the best. Thanks tons:)) Regards, Farnoosh Sheikhi
On Thursday, February 27, 2014 10:37 PM, arun <smartpink...@yahoo.com> wrote: Hi Farnoosh, YOu can try: DataA$percent <- with(DataA,round((Var2/sum(Var2))*100,2)) library(ggplot2) ggplot(DataA,aes(x=Var1,y=percent))+geom_bar(stat="identity",aes(fill=Var1))+geom_text(label=paste0(DataA$percent,"%"),vjust=-0.2,size=4) A.K. On Thursday, February 27, 2014 5:02 PM, farnoosh sheikhi <farnoosh...@yahoo.com> wrote: Hi Arun, I hope all is well. I have a data set like below. I want to get a barplot by ggplot function in R that can change the color of the bins and also shows the percentage of each category on the bin too. Var1=Group Var2=Frequencies Percentage can be calculated as follow: (DataA$Var2/sum(DataA$Var2))*100 DataA <- read.table(text="ID,Var1,Var2 1,A,100 1,B,58 2,C,200 2,D,125 2,E,250",sep=",",header=TRUE,stringsAsFactors=FALSE) Thank you so much for your help and time. Regards, Farnoosh Sheikhi [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.