June 2016
Beginner to intermediate
1783 pages
71h 22m
English
Sometimes, it is useful to have the exact values displayed on a bar chart to enable quick and accurate reading. There is no built-in function in R to do this. In this recipe, we will learn how to do this by writing some custom code.
Once again, we will use the citysales.csv dataset and build upon the graph from the first recipe in this chapter.
Let's make the graph with vertical bars and display the sales values just on top of the bars:
x<-barplot(as.matrix(citysales[,2:4]), beside=TRUE, legend.text=citysales$City, args.legend=list(bty="n",horiz=TRUE), col=brewer.pal(5,"Set1"),border="white", ylim=c(0,100),ylab="Sales Revenue (1,000's of USD)", main="Sales Figures") y<-as.matrix(citysales[,2:4]) ...
Read now
Unlock full access