[R] formula version of sunflowerplot() fails when axis label specified

sina rueeger sina.rueeger at gmail.com
Wed Jun 27 16:09:55 CEST 2012


Hi Gerrit

I did the following: access the function via
graphics:::sunflowerplot.formula, and then commented some lines to see,
where the problem lies. I guess that it is the chunk with "mf <- eval(m,
parent.frame())", but to be honest, I do not know why. My workaround is as
follows:

sunflowerplot.formula2 <- function (formula, data = NULL, xlab = NULL, ylab
= NULL, ..., 
    subset, na.action = NULL) 
{

    if (missing(formula) || (length(formula) != 3L)) 
        stop("formula missing or incorrect")

## >> replaced all the part where "m" is defined, and write instead:
    mf <- model.frame(formula, data)

    require(stats, quietly = TRUE)
    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, 
        ...)
}

I know, the solution is cheap and not as sophisticated as the original
function, but it does the job (for your example).

Best, 
Sina



--
View this message in context: http://r.789695.n4.nabble.com/formula-version-of-sunflowerplot-fails-when-axis-label-specified-tp4634608p4634626.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list