Visualizing variable distributions

Our first plot is a simple one and shows the proportion of votes by each RegionName. As you can see in the plot shown below, the London, North West, and West Midlands regions account for around 55 percent of the observations in the data.

Vote Proportion by Region

To create the plot, we need to create a table for the frequencies of each region in RegionName with the table() function, then we feed that to the prop.table() function, which computes the corresponding proportions, which in turn are used as heights for each bar.

We use the barplot() function to produce the plot, and we can specify some options, ...

Get R Programming By Example 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.