library(tidyverse)
library(plotrix)
library(scales) #I use percent() function from this package 
crackers.df <- read_csv("./data/chap5/crackers-loc.csv")
crackers.df %>%
  count(location) -> location.df
location.df
xlabs <- percent(location.df$n/sum(location.df$n))
pie3D(location.df$n,radius = 1.7,height=0.25,
      theta=0.45,col = c("darkgreen","red","blue"),
      border = "white") -> pos
pos.lab <- c(1.05,2.65,5.45)
pie3D.labels(pos.lab,radius = 1.0, labels = xlabs,
             labelcex=1.2,labelcol = "white")
par(xpd=TRUE)
legend(1.75,0.45,legend=location.df$location,
       cex=0.8,fill = c("darkgreen","red","blue"))