Thank you, Sina,
thank you, David,
I knew how to access the code of sunflowerplot.formula() and that
sunflowerplot() does work in the default version, i.e., w/o formula (but
your suggestions triggered my ambition ;-)).
Below is my -- slightly commented -- version (the search for which was
inspired by Sina's approach) which results from studying the code of
various other plotting functions with formula interface (e.g.,
boxplot.fomula(), stripchart.formula, and, in particular, plot.formula().)
Hth and best regards -- Gerrit
---------------------------------------------------------------------
Dr. Gerrit Eichner Mathematical Institute, Room 212
gerrit.eich...@math.uni-giessen.de Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104 Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109 http://www.uni-giessen.de/cms/eichner
---------------------------------------------------------------------
sunflowerplot.formula <- function( formula, data = NULL,
xlab = NULL, ylab = NULL, ...,
subset, na.action = NULL) {
if(missing(formula) || (length(formula) != 3L))
stop("formula missing or incorrect")
m <- match.call(expand.dots = FALSE)
if (is.matrix(eval(m$data, parent.frame())))
m$data <- as.data.frame(data)
m$... <- NULL
m$xlab <- m$ylab <- NULL # New: Deleting xlab and ylab from m to
# avoid hindrance of the computation of
# the model frame below.
m$na.action <- na.action
require(stats, quietly = TRUE)
m[[1L]] <- as.name("model.frame")
mf <- eval(m, parent.frame()) # Here used to lie the problem.
if (NCOL(mf) != 2L)
stop("'formula' should specify exactly two variables")
if (is.null(xlab))
xlab <- names(mf)[2L]
if (is.null(ylab))
ylab <- names(mf)[1L]
sunflowerplot(mf[[2L]], mf[[1L]],
xlab = xlab, ylab = ylab, # New: To make sure that possibly
# user defined labels are used.
...)
}
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.