gbm.factorplot: Creates ggplots of marginal effect for factorial variables...

View source: R/gbm.factorplot.R

gbm.factorplotR Documentation

Creates ggplots of marginal effect for factorial variables from plot.gbm in gbm.auto.

Description

Creates an additional plot to those created by gbm.plot within gbm.auto. Can also take Bin/Gaus_Best_line.csv or similar csvs directly. Allows changing of x axis levels and all ggplot and ggsave params.

Usage

gbm.factorplot(
  x,
  factorplotlevels = NULL,
  ggplot2guideaxisangle = 0,
  ggplot2labsx = "",
  ggplot2labsy = "Marginal Effect",
  ggplot2axistext = 1.5,
  ggplot2axistitle = 2,
  ggplot2legendtext = 1,
  ggplot2legendtitle = 1.5,
  ggplot2legendtitlealign = 0,
  ggplot2plotbackgroundfill = "white",
  ggplot2plotbackgroundcolour = "grey50",
  ggplot2striptextx = 2,
  ggplot2panelbordercolour = "black",
  ggplot2panelborderfill = NA,
  ggplot2panelborderlinewidth = 1,
  ggplot2legendspacingx = grid::unit(0, "cm"),
  ggplot2legendbackground = ggplot2::element_blank(),
  ggplot2panelbackgroundfill = "white",
  ggplot2panelbackgroundcolour = "grey50",
  ggplot2panelgridcolour = "grey90",
  ggplot2legendkey = ggplot2::element_blank(),
  ggsavefilename = paste0(lubridate::today(), "_Categorical-variable.png"),
  ggsaveplot = ggplot2::last_plot(),
  ggsavedevice = "png",
  ggsavepath = "",
  ggsavescale = 2,
  ggsavewidth = 10,
  ggsaveheight = 4,
  ggsaveunits = "in",
  ggsavedpi = 300,
  ggsavelimitsize = TRUE,
  ...
)

Arguments

x

Input data.frame or tibble or csv (full file address including .csv) to read, must be a categorical variable.

factorplotlevels

Character vector of the variable's levels to reorder the x axis by, all must match those in the first column of the csv exactly. Default NULL orders from high to low Y value.

ggplot2guideaxisangle

Default 0. Set at e.g. 90 to rotate.

ggplot2labsx

Default: "".

ggplot2labsy

Default: "Marginal Effect".

ggplot2axistext

Default: 1.5.

ggplot2axistitle

Default: 2.

ggplot2legendtext

Default: 1.

ggplot2legendtitle

Default: 1.5.

ggplot2legendtitlealign

Default: 0, # otherwise effect type title centre aligned for some reason.

ggplot2plotbackgroundfill

Default: "white", white background.

ggplot2plotbackgroundcolour

Default: "grey50", background lines.

ggplot2striptextx

Default: 2.

ggplot2panelbordercolour

Default: "black".

ggplot2panelborderfill

Default: NA.

ggplot2panelborderlinewidth

Default: 1.

ggplot2legendspacingx

Default: unit(0, "cm"), # compress spacing between legend items, this is min.

ggplot2legendbackground

Default: ggplot2::element_blank().

ggplot2panelbackgroundfill

Default: "white".

ggplot2panelbackgroundcolour

Default: "grey50".

ggplot2panelgridcolour

Default: "grey90".

ggplot2legendkey

Default: ggplot2::element_blank().

ggsavefilename

Default: paste0(saveloc, lubridate::today(), "_SankeyAlluvial_EMT.SoEv-EfTyp_Col-EfSz.png").

ggsaveplot

Default: last_plot().

ggsavedevice

Default: "png".

ggsavepath

Default: "".

ggsavescale

Default: 2.

ggsavewidth

Default: 10.

ggsaveheight

Default: 4.

ggsaveunits

Default: "in".

ggsavedpi

Default: 300.

ggsavelimitsize

Default: TRUE.

...

Allow params to be called from higher function esp gbm.auto.

Details

'r lifecycle::badge("experimental")

Value

Factorial ggplot saved with users preferred location and name.

Author(s)

Simon Dedman, simondedman@gmail.com


SimonDedman/gbm.auto documentation built on Oct. 9, 2024, 8:57 p.m.