MakePie: Utility to make a ggplot pie chart

Description Usage Arguments Value Examples

Description

Utility to make a ggplot pie chart

Usage

1
2
3
MakePie(type, percent, type.title.str = "Title String Here",
  segment.name = "Type", segment.cols = NULL, segment.breaks = NULL,
  label.size = 4)

Arguments

type

- a character vector of pie segments names

percent

- a numeric vector of pie segments values (make them add to 100)

type.title.str

= 'Title String Here' - a title for the plot

segment.name

= 'Type' - the legend title

segment.cols

= NULL - used to control colours of the segments

segment.breaks

= NULL - used to control colours of the segments

label.size

= 4 - used to adjust percent text label size

Value

a ggplot object with your pie chart

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
# Get these two vectors in the order you need and make sure
# the percent add up to 100
type<-c('Comp1','Comp2','Comp3','Other')
percent<-c(65,20,10,5)

#Set up the pie chart characteristics
pie.trace.cols<-c('Comp1'='cornflowerblue','Comp2'='forestgreen','Comp3'='orange','Other'='indianred2')
pie.breaks<-c('Comp1','Comp2','Comp3','Other')
pie.segment.name<-'Variation Type'
type.title.str<-'Three Variation Components'

p<-MakePie(type,percent,type.title.str
           ,segment.name=pie.segment.name
           ,segment.cols=pie.trace.cols
           ,segment.breaks=pie.breaks)
print(p)

## End(Not run)

StatsResearch/RobsRUtils documentation built on May 9, 2019, 3:04 p.m.