Skip to content

Instantly share code, notes, and snippets.

@jeffreyiacono
Last active December 11, 2015 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreyiacono/4619061 to your computer and use it in GitHub Desktop.
Save jeffreyiacono/4619061 to your computer and use it in GitHub Desktop.
example of lattice plots with medians for x, y and linear regression lines for two grouped sets of data
library(lattice)
x <- rnorm(100)
y <- x + rnorm(100, sd = 0.5)
f <- gl(2, 50, labels = c("Group 1", "Group 2"))
xyplot(y ~ x | f,
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.lmline(x, y, col = 2)
panel.abline(h = median(y), lty = 2)
panel.abline(v = median(x), lty = 2)
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment