Learn R Programming

loa (version 0.3.1.1)

1.5.loaBarPlot: loaBarPlot

Description

Bar plot variation using for Student Project.

Usage

loaBarPlot(x, y=NULL, groups=NULL, cond=NULL, 
            data=NULL, ..., drop.nas=TRUE, stat=NULL)

Value

loaBarPlot returns trellis objects, much like conventional lattice plot functions.

Arguments

x

Either the x case for the bar plot or a plot formula. If the x case, typically a vector of factor or grouping terms, used to assign x positions in bar plot. If a plot formula, a plot description in the format y~x|cond, where x is a factor or grouping term and y and cond are optional.

y

(Optional) The y case for the bar plot, typically a vector of numeric terms, used with stat when calculating summary information for bar plots.

groups, cond

(Optional) The group case for the bar plot, typically a vector of factor or grouping terms.

data

(Optional) if supplied, the assumed source of the plot elements, x, y, groups and cond, typically a data.frame.

...

Additional arguments, passed on to lattice function.

drop.nas

Option to drop NAs before plotting results, default TRUE.

stat

If supplied, the function used to summarise y data after grouping by x, groups and cond. By default, this counts x cases if y is not supplied, or calculates sum of y values if these are supplied.

Author

Karl Ropkins

Details

loaBarPlot summarises supplied plot data and generates a bar plot using the lattice framework.

References

These function makes extensive use of code developed by others.

As elsewhere, the use of lattice is also gratefully acknowledged:

lattice: Sarkar, Deepayan (2008). Lattice: Multivariate Data Visualization with R. Springer, New York. ISBN 978-0-387-75968-5

See Also

In loa: listUpdate and colHandler.

In other packages: barchart in lattice.

Examples

Run this code

## Example 1
## Basic bar plot usage

  loaBarPlot(Species, Sepal.Width, data=iris, stat=mean)

#or equivalent using formula 
if (FALSE) {
  loaBarPlot(Sepal.Width~Species, data=iris, stat=mean)}
 

Run the code above in your browser using DataLab