Learn R Programming

simFrame (version 0.1.2)

simBwplot-methods: Methods for producing box-and-whisker plots

Description

Produce box-and-whisker plots.

Usage

## S3 method for class 'SimResults':
simBwplot(x, true = NULL, epsilon, NArate, select, \dots)

Arguments

x
the simulation results to be plotted, i.e., an object of class "SimResults".
true
a numeric vector giving the true values. If supplied, reference lines are drawn in the corresponding panels.
epsilon
a numeric value specifying a contamination level. If supplied, the values corresponding to that contamination level are extracted from the simulation results and plotted.
NArate
a numeric value specifying a missing value rate. If supplied, the values corresponding to that missing value rate are extracted from the simulation results and plotted.
select
a character vector specifying the columns to be plotted. It must be a subset of the colnames slot of x, which is the default.
...
additional arguments to be passed down to bwplot.

See Also

simDensityplot, simXyplot, bwplot, SimResults

Examples

Run this code
## for reproducibility
set.seed(1234)

## function for generating data
grnorm <- function(n, means) {
    group <- sample(1:2, n, replace=TRUE)
    data.frame(group=group, value=rnorm(n) + means[group])
}

## control objects for data generation and contamination
means <- c(0, 0.5)
dc <- DataControl(size = 500, distribution = grnorm, 
    dots = list(means = means))
cc <- DCARContControl(target = "value", 
    epsilon = 0.1, dots = list(mean = 10))

## function for simulation runs
sim <- function(x) {
    c(mean = mean(x$value), 
        trimmed = mean(x$value, trim = 0.1), 
        median = median(x$value))
}

## run simulation
results <- runSimulation(dc, nrep = 50, 
    contControl = cc, design = "group", fun = sim)

## plot results
simBwplot(results, true = means)

Run the code above in your browser using DataLab