Domestic Beer in the U.S. 2013 | Dollar Salessource: The Atlantic, April 201418%7%6%6%3%3%2%2%1%1%50%Bud LightCoors LightBudweiserMiller LightNatural LightBusch LightMichelob UltraBuschKeystone LightMiller High LifeOther

  1. require(magrittr)
  2. require(dplyr)
  3. require(rCharts)
  4. beerPie <- rCharts$new()
  5. beerPie$setLib("//timelyportfolio.github.io/rChartsExtra/d3pie")
  6. # source : The Atlantic April 2014 "The State of American Beer"
  7. # //www.theatlantic.com/business/archive/2014/04/the-state-of-american-beer/360583/
  8. beerData <- rbind(
  9. c("Bud Light",5946776000),
  10. c("Coors Light",2360430000),
  11. c("Budweiser",2110352000),
  12. c("Miller Light",1868866000),
  13. c("Natural Light",1122770000),
  14. c("Busch Light",844276000),
  15. c("Michelob Ultra",777196700),
  16. c("Busch",673394400),
  17. c("Keystone Light",493993000),
  18. c("Miller High Life",476895100),
  19. c("Category total",23707870000)
  20. ) %>% data.frame(stringsAsFactors = F) %>% #make data.frame
  21. set_colnames(c("label","value")) %>% #set our column names
  22. mutate(value = as.numeric(value)) #make our values numeric
  23. #change total row to an other row
  24. beerData[nrow(beerData),1] <- "Other"
  25. beerData[nrow(beerData),2] <- sum(beerData[-nrow(beerData),2])
  26. beerPie$params$chartspec <- list(
  27. header = list(
  28. title = list(
  29. text = "Domestic Beer in the U.S. 2013 | Dollar Sales"
  30. ),
  31. subtitle = list(
  32. text = "source: The Atlantic, April 2014"
  33. )
  34. )
  35. ,data = list(
  36. content = beerData
  37. )
  38. ,labels = list(
  39. lines = list(style = "straight")
  40. )
  41. )
  42. beerPie