prism.plots: Plot prism-like Plots

View source: R/7-fliegen-schiss-plot.R

prism.plotsR Documentation

Plot prism-like Plots

Description

gestohlen von Dustin Fife

Usage

prism.plots(
  formula,
  data,
  fun = median,
  interquartile = TRUE,
  spreadfunc = function(x) {
     return(1.96 * sd(x)/sqrt(length(x)))
 },
  def.axis = TRUE,
  jitter = TRUE,
  add = FALSE,
  col = "gray",
  pch = 16,
  ...
)

Arguments

formula

a formula object with the quantitative variable as the response variable (e.g., Var~group).

data

a dataset containing the variables indicated in formula

fun

what function should be used to indicate the center of the distribution. Defaults to median.

interquartile

Should the interquartile range be plotted? Defaults to TRUE.

spreadfunc

what function should be used to calculate the spread of the distribution? If interquartile=TRUE, this argument will be ignored. The default (when not ignored) is to produce a 95% confidence interval (1.96*sd(x)/sqrt(n)).

def.axis

Logical. Should the default axes be used?

jitter

Logical. Should the y values be jittered as well?

add

Should the plot be added to an existing plot?

col

What color should the dots be painted? Defaults to gray.

...

other arguments passed to plot

Examples


require(lattice)
require(latticeExtra)
require(effects)

prism.plots(count ~ spray, data = InsectSprays, fun = mean)

Insect <- lm(count ~ spray, data = InsectSprays)
stripplot(
  count ~ spray,
  data = InsectSprays,
  # ylim=c(-10,70),
  ylab = "Insect count",
  xlab = "The type of spray",
  jitter.data = TRUE,
  panel = function(x, y, ...) {
    # panel.conf.int(x, y, ...)
    panel.stripplot(x, y, pch = 19, col = "gray50", ...)
    # panel.points(x,y, pch=19,...)
    # panel.mean(x,y,  ...)
    panel.median(x, y, ...)
    panel.sig.bars(Insect, include.stars = FALSE, offset = .4)
  }
)


p <- stripplot(
  count ~ spray,
  data = InsectSprays,
  jitter.data = TRUE,
  pch = 20,
  col = "gray50"
)
p + layer(panel.sig.bars(Insect, include.stars = FALSE, offset = .4))

p2 <- plot(effect("spray", Insect), lty = 0 , main = "Effectiveness of Insect Sprays")
p2 +  layer(panel.sig.bars(Insect, include.stars = FALSE, offset = .4))

stp4/stp25plot documentation built on March 29, 2025, 4:26 p.m.