Bug 14541 - Wishlist: improvements to sunflowerplot
Summary: Wishlist: improvements to sunflowerplot
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: R 2.12.2
Hardware: All All
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2011-03-25 16:06 UTC by Reto Bürgin
Modified: 2011-03-31 09:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Reto Bürgin 2011-03-25 16:06:08 UTC
Hi there,

In our opinion the sunflowerplot of the package "graphics" should be improved: 

i)  allow formula writing
ii) allow NA values

We suggest something similar to this improved version of sunflowerplot: 

sunflowerplot2 <- function (x, y = NULL, data=NULL, main=NULL, sub="", ...)
{
  if (!is.null(data) & is.null(main))
    main <- deparse(substitute(data))
  
  if (class(x) =="formula"){
    xlab <- all.vars(formula(x))[2]
    ylab <- all.vars(formula(x))[1]
    ind <- apply(is.na(data[ ,c(xlab, ylab)]), 1, sum) > 0
    ind.nbr <- which(ind)
    data.temp <- data[!ind,c(xlab, ylab)]
  }
  if (is.data.frame(x)){
    xlab <- names(x)[1]
    ylab <- names(x)[2]
    ind <- apply(is.na(x), 1, sum) > 0
    ind.nbr <- which(ind)
    data.temp <- x[!ind,]
  }
  if (is.vector(x)){
    xlab <- deparse(substitute(x))
    ylab <- deparse(substitute(y))
    data.temp2 <- cbind(x, y)
    ind <- apply(is.na(data.temp2), 1, sum) > 0
    ind.nbr <- which(ind)
    data.temp <- data.temp2[!ind,]
  }
  sunflowerplot(x=data.temp[,xlab], y=data.temp[,ylab], xlab=xlab,
                ylab=ylab, main=main, ...)
  warning(paste(length(ind.nbr),"items were excluded due to missings: ",
                paste(ind.nbr,collapse=" ")))
}

Regards,

Sina Rueeger (rusa@zhaw.ch) and 
Reto Buergin (rbuergin@gmx.ch)
Comment 1 Brian Ripley 2011-03-27 05:01:54 UTC
This is really odd: it does not 'allow NA values': it simply omits them,
something we have na.omit for so does not need to be part of sunflowerplot.
We also have rowSums ....

Please note what the FAQ says about wishlist items.
Comment 2 Brian Ripley 2011-03-31 09:34:06 UTC
Formula interface added for 2.14.0