plot.rMix: 'plot' Method for 'rMix' Objects

Description Usage Arguments See Also Examples

View source: R/0_Mix_utils.R

Description

plot method for rMix objects, plotting the histogram of the random sample, with the option of additionally plotting the components (stacked or plotted over one another).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## S3 method for class 'rMix'
plot(
  x,
  xlab = attr(obj, "name"),
  ylim = NULL,
  main = paste("Histogram of", attr(obj, "name")),
  breaks = NULL,
  col = "grey",
  components = TRUE,
  stacked = FALSE,
  component.colors = NULL,
  freq = TRUE,
  plot = TRUE,
  ...
)

Arguments

x

object of class rMix.

xlab

label for the x axis with default.

ylim

range of y values to use, if not specified (or containing NA), default values are used.

main

main title of the plot, defaulting to the rMix object name.

breaks

see hist. If left unspecified the function tries to construct reasonable default values.

col

colour to be used to fill the bars of the histogram evaluated on the whole data.

components

logical flag indicating whether the plot should show to which component the observations belong (either by plotting individual histograms or by overlaying a stacked barplot), defaulting to TRUE. Ignored if plot is FALSE.

stacked

logical flag indicating whether the component plots should be stacked or plotted one over another, defaulting to FALSE. Ignored if components is FALSE or ignored itself.

component.colors

colors for the component plots. If unspecified, default colors are used.

freq

logical flag, if TRUE, the histogram graphic is a representation of frequencies, if FALSE, probability densities. See hist.

plot

logical flag, if TRUE (default), a histogram is plotted, otherwise a list of breaks and counts is returned. See hist.

...

further arguments passed to the histogram function evaluated on the whole data as well as the component data (if components is TRUE and stacked is FALSE).

See Also

rMix for the construction of rMix objects.

Examples

1
2
3
4
5
6
7
# define 'Mix' object
normLocMix <- Mix("norm", discrete = FALSE, w = c(0.3, 0.4, 0.3), mean = c(10, 13, 17),
                  sd = c(1, 1, 1))
# generate n random samples
set.seed(1)
x <- rMix(1000, normLocMix)
plot(x)

mixComp documentation built on Feb. 25, 2021, 5:07 p.m.