# R Statistics Essential Training
# Ex02_02
# Creating pie charts for categorical variables

# LOAD DATASETS PACKAGE
data("chickwts")

# ONE ROW PER CASE
data(chickwts)

# Create a table with frequencies
feeds <-  table(chickwts$feed)
feeds
## 
##    casein horsebean   linseed  meatmeal   soybean sunflower 
##        12        10        12        11        14        12
# Make the pie chart with the defaults
pie(feeds)

# Modify the pie chart
pie(feeds[order(feeds, decreasing = TRUE)],
    init.angle = 90, #??? Starts as 12 o´clock instead of 3
    clockwise = TRUE, # Default is FALSE
    col = c("seashell", "cadetblue2", "lightpink", "lightcyan", "plum1", "papayawhip"),
    main = "Pie Chart of Feeds from chickwts")