Mbargraph {biology}R Documentation

~~function to do ... ~~

Description

~~ A concise (1-5 lines) description of what the function does. ~~

Usage

Mbargraph(dv, factorlist, ylabel = paste("Mean", deparse(substitute(dv))), xlabel = "", type = "b", ymin = NULL, ymax = NULL, errorbars = "se", symbols = "")

Arguments

dv ~~Describe dv here~~
factorlist ~~Describe factorlist here~~
ylabel ~~Describe ylabel here~~
xlabel ~~Describe xlabel here~~
type ~~Describe type here~~
ymin ~~Describe ymin here~~
ymax ~~Describe ymax here~~
errorbars ~~Describe errorbars here~~
symbols ~~Describe symbols here~~

Details

~~ If necessary, more details than the description above ~~

Value

~Describe the value returned If it is a LIST, use
comp1 Description of 'comp1'
comp2 Description of 'comp2'
...

Note

~~further notes~~

~Make other sections like Warning with Warning .... ~

Author(s)

~~who you are~~

References

~put references to the literature/web site here ~

See Also

~~objects to See Also as help, ~~~

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (dv, factorlist, ylabel = paste("Mean", deparse(substitute(dv))), 
    xlabel = "", type = "b", ymin = NULL, ymax = NULL, errorbars = "se", 
    symbols = "") 
{
    means <- tapply(dv, factorlist, mean, na.rm = T)
    sds <- tapply(dv, factorlist, sd, na.rm = T)
    ns <- tapply(dv, factorlist, function(x) length(na.omit(x)))
    ses <- sds/sqrt(ns)
    ys <- pretty(c(means - ses, means + (2 * ses)))
    if (!is.null(ymin)) 
        ys <- c(ys, ymin)
    if (!is.null(ymax)) 
        ys <- c(ys, ymax)
    if (type == "b") {
        if (is.list(factorlist)) {
            xs <- barplot(means, ylim = c(min(ys), max(ys)), 
                beside = T, axes = F, xpd = F, axisnames = T, 
                axis.lty = 2, legend.text = T)
            if (xlabel == "") {
                xlabel = deparse(substitute(factorlist)[[3]])
            }
        }
        else {
            xs <- barplot(means, ylim = c(min(ys), max(ys)), 
                beside = T, axes = F, xpd = F, axis.lty = 1, 
                legend.text = F)
            if (xlabel == "") {
                xlabel = deparse(substitute(factorlist))
            }
        }
    }
    else {
        if (is.list(factorlist)) {
            xs <- barplot(means, ylim = c(min(ys), max(ys)), 
                beside = T, axes = F, xpd = F, axis.lty = 1, 
                legend.text = F, plot = FALSE)
            interaction.plot(factorlist[[1]], factorlist[[2]], 
                dv, ylim = c(min(ys), max(ys)))
        }
        else {
            xs <- plotMeans(means, factorlist[[1]], factorlist[[2]])
        }
    }
    library(Hmisc)
    errbar(xs, means, means + ses, means - ses, add = T)
    axis(2, las = 1)
    mtext(2, text = ylabel, line = 3, cex = 1.5)
    mtext(1, text = xlabel, line = 3, cex = 1.5)
    lines(c(0, max(xs) + 0.5), c(min(ys), min(ys)))
    Mgraph <- data.frame(xs, means = means + ses + ((max(ys) - 
        min(ys))/20))
    if (exists("symbols")) {
        text(xs, means + ses, labels = symbols, pos = 3)
    }
  }

[Package biology version 1.0 Index]