Learn R Programming

mc2d (version 0.2.0)

gghist: 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 mcnode gghist( x, griddim = NULL, xlab = names(x), ylab = "Frequency", main = "", bins = 30, which = NULL, ... )

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

Value

a ggplot object.

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.

Author

Yu Chen and Regis Pouillot

See Also

[hist.mc()]

Examples

Run this code
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")

Run the code above in your browser using DataLab