Creating bar charts with vertical error bars

Bar charts with error bars are commonly used in analyzing and reporting results of scientific experiments. In this recipe, we will learn how to add error bars to a bar chart in a similar way to the recipe for scatter plots in Chapter 4, Creating Scatter Plots.

Getting ready

We will continue using the citysales.csv example dataset in this recipe. Make sure that you have loaded it into R and type in the recipe at the R prompt. You might also want to save the recipe as a script so that you can easily run it again later.

How to do it...

One change we will make in this recipe is that we will use the transpose of the citysales dataset (turns rows into columns and columns into rows). So, first let's create the ...

Get R: Data Analysis and Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.