To begin, we will expand our Chapter 8 bar chart using arguments specifically designed for the
barplot(...)
function. We will also become familiar with two different types of bar charts.
Open R and set your working directory:
> #set the R working directory > #replace the sample location with one that is relevant to you > setwd("/Users/johnmquick/rBeginnersGuide/")
Load the Chapter 9 workspace. It contains the necessary information for this chapter:
> #load the chapter 9 workspace > load("rBeginnersGuide_Ch_09_ReadersCopy.RData")
Use the
names
,width
, andspace
arguments to customize a chart's bars:> #modify the chapter 8 bar chart that compared the mean durations of the battle methods > #use the names argument to assign a text label to each bar > #the names argument receives a vector containing text labels for each of the chart's bars > barAllMethodsDurationNames <- c("Fire", "Ambush", "Head to Head", "Surround") > ...