Pie Chart in R
Enter the data vectors. This data is the percentages by weight of elements in the human body symbols = c("O", "C", "H", "N", "Ca", "P", "K", "S", "Na", "Cl", "Mg") names = c("Oxygen", "Carbon", "Hydrogen", "Nitrogen", "Calcium", "Phosphorus", "Potassium", "Sulfur", "Sodium", "Chlorine", "Magnesium") number = c(8, 6, 1, 7, 20, 15, 19, 16, 11, 17, 12) percents = c(65, 18.5, 9.5, 3.3, 1.5, 1.0, 0.4, 0.3, 0.2, 0.2, 0.1)
Make a pie chart
Try a legend instead
Not sure students will be able to do this, but let’s try: Click on Packages, then Install
Type in plotrix and click Install
Now shows up in list
3D pie chart fro plotrix
With legend
Ggplot2 Ggplot2 is a very extensive library for R After we see how installing the simpler plotrix library goes, we may use ggplot2