Mbargraph1 {biology} | R Documentation |
~~ A concise (1-5 lines) description of what the function does. ~~
Mbargraph1(x.factor, trace.factor = NULL, response, legend = T, names.arg = NULL, xlabel = deparse(substitute(x.factor)), axes = T, xlabs = levels(x.factor), ylabel = paste("Mean", deparse(substitute(response))), ylim = NULL, errorbars = "se", col = c(0, 1))
x.factor |
~~Describe x.factor here~~ |
trace.factor |
~~Describe trace.factor here~~ |
response |
~~Describe response here~~ |
legend |
~~Describe legend here~~ |
names.arg |
~~Describe names.arg here~~ |
xlabel |
~~Describe xlabel here~~ |
axes |
~~Describe axes here~~ |
xlabs |
~~Describe xlabs here~~ |
ylabel |
~~Describe ylabel here~~ |
ylim |
~~Describe ylim here~~ |
errorbars |
~~Describe errorbars here~~ |
col |
~~Describe col here~~ |
~~ If necessary, more details than the description above ~~
~Describe the value returned If it is a LIST, use
comp1 |
Description of 'comp1' |
comp2 |
Description of 'comp2' |
...
....
~~further notes~~
~Make other sections like Warning with section{Warning }{....} ~
~~who you are~~
~put references to the literature/web site here ~
~~objects to See Also as help
, ~~~
##---- 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 (x.factor, trace.factor = NULL, response, legend = T, names.arg = NULL, xlabel = deparse(substitute(x.factor)), axes = T, xlabs = levels(x.factor), ylabel = paste("Mean", deparse(substitute(response))), ylim = NULL, errorbars = "se", col = c(0, 1)) { if (is.null(trace.factor)) { cells <- tapply(response, x.factor, mean, na.rm = T) sds <- tapply(response, x.factor, sd, na.rm = T) ns <- tapply(response, x.factor, function(x) length(na.omit(x))) ses <- sds/sqrt(ns) col <- col[2] } else { cells <- t(tapply(response, list(x.factor, trace.factor), mean, na.rm = T)) sds <- t(tapply(response, list(x.factor, trace.factor), sd, na.rm = T)) ns <- t(tapply(response, list(x.factor, trace.factor), function(x) length(na.omit(x)))) ses <- sds/sqrt(ns) leg.text <- levels(trace.factor) } ys <- pretty(c(cells - ses, cells + (2 * ses))) if (!is.null(ylim)) ys <- pretty(ylim) if (!is.null(trace.factor)) { xs <- barplot(cells, ylim = c(min(ys), max(ys)), beside = T, axes = F, xpd = F, axisnames = F, axis.lty = 2, legend.text = F, col = col) } else { xs <- barplot(cells, ylim = c(min(ys), max(ys)), beside = T, axes = F, xpd = F, axis.lty = 1, legend.text = F, space = 1, col = col) } if (axes == T) { if (is.null(trace.factor)) xm <- xs else xm <- apply(xs, 2, median) axis(2, las = 1) axis(1, at = xm, lab = xlabs, padj = 1, mgp = c(0, 0, 0)) mtext(2, text = ylabel, line = 3, cex = 1.5) mtext(1, text = xlabel, line = 3, cex = 1.5) box(bty = "l") } arrows(xs, cells, xs, cells + ses, code = 3, angle = 90, len = 0.05) if (legend != F & !is.null(trace.factor)) legend("topright", leg = legend, fill = col, col = col, bty = "n", cex = 1.5) }