prettypie: prettypie

View source: R/plot_special.R

prettypieR Documentation

prettypie

Description

A pie chart. prettypie is stupid, ignore it; use prettypie2,

Usage

prettypie(dat, main = NULL, sub = NULL, note = NULL, ...)

prettypie2(
  x,
  group = 1,
  labels = NA,
  col.group = NULL,
  radius = c(0.7, 1),
  ...
)

Arguments

dat

data

main, sub, note

overall title, sub-title, and note for plot

...

additional graphical parameters passed to par

x

numeric vector representing the size for each slice

group

vector identifying groups of slices (used by col)

labels

vector of labels for individual slices; if NA, no labels will be drawn; if NULL, slices will be labeled sequentially

col.group

colors for each group of slices

radius

radius for inner and outer pie (usually in [0,1])

Examples

browsers <- source(system.file('source','browsers.r', package = 'plotr'))$value
browsers <- within(browsers, total <- ave(share, browser, FUN = sum))
browsers <- browsers[c('browser', 'version', 'share', 'total')]

m1 <- 'Browser market share, April 2011'
s1 <- 'stackoverflow.com:::maryam'
n1 <- '/questions/26748069/ggplot2-pie-and-donut-chart-on-same-plot'
prettypie(browsers, m1, s1, n1)


disease <- source(system.file('source','disease.r', package = 'plotr'))$value
disease <- disease[c('Disease', 'Acosts60', 'Pcosts60', 'Patients60', 'Total60')]

m2 <- 'Cost of getting sick'
s2 <- 'Inside: Personal Costs, outside: Insurer Costs'
n2 <- 'visualization.geblogs.com/visualization/health_costs/'
prettypie(disease, m2, s2, n2)

## Not run: 
pdf('~/desktop/prettypie-browsers.pdf', width = 15, height = 11, bg = 'snow')
prettypie(browsers, m1, s1, n1)
dev.off()

pdf('~/desktop/prettypie-disease.pdf', width = 15, height = 11, bg = 'snow')
prettypie(disease, m2, s2, n2)
dev.off()

## End(Not run)

## basic usage
prettypie2(mtcars$mpg)

prettypie2(mtcars$mpg, group = mtcars$gear)

with(mtcars,
  prettypie2(mpg, interaction(gear, cyl), rownames(mtcars), cex = 0.8)
)


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.