With our data prepared for analysis, we can now consider the potential combat options available to the Shu army. Ultimately, you have the responsibility to use these data to make practical and meaningful decisions about future courses of action. To achieve success, you will need to fully consider the situation and form a sound basis for reasoned decision-making. This requires you to build upon the techniques that we practiced in Chapter 4 and to explore new ones in R.
In this chapter, we will focus on assessing the information that is available to us and using it to weigh potential decisions. By the end of this chapter, you will be able to:
In Chapter 4, we saved our R workspace for the first time. As you saw in the previous chapter, we can use the load(file)
function to continue where we left off.
You also created variables to hold the mean number of soldiers engaged for the Shu and Wei forces, based on historical data from 120 battles between the kingdoms. Let us make an initial inference about these values:
> #set the R working directory > #replace the sample location with one that is relevant to you > setwd("/Users/johnmquick/rBeginnersGuide/")
> #load the chapter 5 workspace > load("rBeginnersGuide_Ch_05_ReadersCopy.RData") > #verify the contents of the workspace >ls()
> #mean number of Shu soldiers engaged in battle > meanSoldiersShu [1] 21035.83 > #mean number of Wei soldiers engaged in battle > meanSoldiersWei [1] 21937.5
meanSoldierRatioWeiShu
. Then display the result:> #ratio of mean Wei soldiers to Shu soldiers > meanSoldierRatioWeiShu <- meanSoldiersWei / meanSoldiersShu > #display the contents of meanSoldierRatioWeiShu > meanSoldierRatioWeiShu [1] 1.042863
> #how many Wei soldiers would we expect to engage in battle if our Shu forces numbered 100,000? > 100000 * meanSoldierRatioWeiShu [1] 104286.3
After preparing R, we used our historic battle data to calculate the ratio of the mean Wei soldiers engaged in past conflicts to the mean number of Shu soldiers. The ratio value of 1.04 suggests that the Wei army brings roughly 4% more soldiers into battle than Shu does on average. We can use this ratio in our predictions and plans for future battles. In general, we expect the Shu army to be outnumbered regardless of the conflict. Inferences like this one may have implications for the combat strategies that we choose to employ.