my.barplot <- function(data, labels, inside=F, signif.digits=1, ...) { # Draw a barplot with corresponding frequency (%) # * Input * # data : a table # labels : a vector of labels for y-axis # inside : if TRUE, write the corresponding frequency in the middle # of the bar, else at its end. If the bar is not as large as # the text, then it is written at the end of the bar. # * Output * # graphical side-effects # * Test * # data <- rbinom(70000,5,0.2); my.barplot(table(data),1:6) # 29/11/06, chl hoffset <- .025*max(data) labs <- round(data/sum(data)*100,signif.digits) tmp <- barplot(data, horiz=T, xlim=c(0,max(data)+15*hoffset), names.arg=labels, las=1, ...) if (inside) { xx <- ifelse(strwidth(labs)