qpie: Draw and save a pie chart quickly (via ggplot2).

View source: R/ggExpress.R

qpieR Documentation

Draw and save a pie chart quickly (via ggplot2).

Description

This all-in-one function draws, annotates, displays and saves a pie chart of a distribution provided as a numeric table It is a wrapper around ggpubr::ggpie(), with the automation of many features. All ggpubr parameters can be accessed through the ... argument.

Usage

qpie(
  vec,
  also.pdf = FALSE,
  save.obj = FALSE,
  ext = MarkdownHelpers::ww.set.file.extension(default = "png", also_pdf = also.pdf),
  plot = TRUE,
  save = TRUE,
  mdlink = MarkdownHelpers::unless.specified("b.mdlink", def = FALSE),
  plotname = FixPlotName(substitute(vec)),
  filename = NULL,
  subtitle = NULL,
  suffix = NULL,
  caption = suffix,
  caption.ext = TRUE,
  NoLegend = FALSE,
  LegendSide = TRUE,
  LegendTitle = "",
  pcdigits = 2,
  NamedSlices = FALSE,
  custom.order = FALSE,
  extended.canvas = TRUE,
  palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb",
    "uchicago")[4],
  custom.margin = TRUE,
  max.categories = 100,
  max.names = 10,
  decr.order = TRUE,
  both_pc_and_value = FALSE,
  labels = "names",
  w = 7,
  h = 5,
  ...
)

Arguments

vec

The variable to plot.

also.pdf

Save plot in both png and pdf formats.

save.obj

Save the ggplot object to a file. Default: FALSE.

ext

File extension (.pdf / .png).

plot

Display the plot.

save

Save the plot into a file.

mdlink

Insert a .pdf and a .png image link in the markdown report, set by "path_of_report".

plotname

The title of the plot and the name of the file (unless specified in filename).

filename

Manually provided filename (optional). Default: parse from plotname,

subtitle

Optional subtitle text added below the title. Default is NULL.

suffix

Optional suffix added to the filename. Default is NULL.

caption

Optional text added to bottom right corner of the plot. Default = suffix

NoLegend

NoLegend

LegendSide

LegendSide

LegendTitle

LegendTitle

pcdigits

pcdigits

NamedSlices

NamedSlices

custom.order

custom.order

extended.canvas

Make an extended canvas, default: T

palette_use

GGpubr Color palette to use.

custom.margin

custom plot margin, default: T

max.categories

Maximum number of categories to be shown as a seprate slice

max.names

The maximum number of names still to be shown on the axis.

decr.order

Slices in the order of df. By default would ordered alphabetically in the plot.

both_pc_and_value

Report both percentage AND number.

labels

Slice labels. Set to NULL to remove slice names.

w

Width of the plot.

h

Height of the plot.

...

Pass any other parameter of the corresponding plotting function(most of them should work).

Examples

xvec <- c("A" = 12, "B" = 29)
qpie(vec = xvec)

vertesy/ggExpress documentation built on Nov. 24, 2024, 10:44 p.m.