gghist: Histogram of a Monte Carlo Simulation (ggplot version)

View source: R/gghist.R

gghistR Documentation

Histogram of a Monte Carlo Simulation (ggplot version)

Description

Shows histogram of a ‘⁠mcnode⁠’ or a ‘⁠mc⁠’ object by ggplot framework.

Usage

gghist(x, ...)

## S3 method for class 'mcnode'
gghist(
  x,
  griddim = NULL,
  xlab = names(x),
  ylab = "Frequency",
  main = "",
  bins = 30,
  which = NULL,
  ...
)

## S3 method for class 'mc'
gghist(
  x,
  griddim = NULL,
  xlab = names(x),
  ylab = "Frequency",
  main = "",
  bins = 30,
  ...
)

Arguments

x

an 'mc' or an 'mcnode' object

...

Further arguments to be passed to geom_histogram()

griddim

A vector of two integers, indicating the size of the grid of the graph. If 'NULL', the grid is calculated to produce a "nice" graph.

xlab

Vector of labels for the x-axis. If 'NULL', use the name of the node.

ylab

Vector of labels for the y-axis.

main

Vector of main titles of the graph

bins

Number of bins. Defaults to 30.

which

An argument used for a multivariate 'mcnode'. Can specify which variate plot to display. When variates are more than one, the output will be saved in a plot list by default or use the number of which variate to display.

Value

a ggplot object.

Author(s)

Yu Chen and Regis Pouillot

See Also

[hist.mc()]

Examples

data(total)
# When mcnode has one variate
gghist(xV)
# When mcnode has two variates, the two plots will be saved in a list 
# if affected to a variable
gplots <- gghist(xVUM) 
# show the first variate plot of xVUM mcnode
gplots[[1]] 
# directly show the first variate plot of xVUM mcnode
gghist(xVUM, which = 1) #directly show the first variate plot of xVUM mcnode
# Post process
gplots[[1]] + ggplot2::geom_histogram(color = "red",fill="blue")


mc2d documentation built on June 22, 2024, 10:54 a.m.