pie(...)

The primary arguments used in the pie(...) function are x and labels:

  • x: the numerical values for the pie's slices. These must be nonnegative and input in vector form.
  • labels: the text labels for the pie's slices. These must be input in vector form.

Consequently, the pie chart function takes on the following basic form:

pie(x = sliceData, labels = sliceText)

Where sliceData and sliceText are in vector form.

To create our pie chart, we first calculated the cost information that we wished to display and stored it in a vector variable, like so:

> pieFireGoldCostSlices <- c(6792, 993208)

Next, we created a vector to hold the text labels for our pie's slices:

> pieFireGoldCostLabels <- c("mission cost", "remaining funds")

Then we customized our chart with a main title and specific colors, before executing our complete pie(...) function:

> pie(x = pieFireGoldCostSlices, labels = pieFireGoldCostLabels,
main = pieFireGoldCostMain, col = pieFireGoldCostSpecificColors)

Lastly, we added a legend to our chart to further clarify its components:

> legend(x = "bottom", legend = pieFireGoldCostLabels,
fill = pieFireGoldCostSpecificColors)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.27.74