From Thorn.Thaler at rdls.nestle.com  Mon Nov  4 10:54:59 2013
From: Thorn.Thaler at rdls.nestle.com (Thaler,Thorn,LAUSANNE,Applied Mathematics)
Date: Mon, 4 Nov 2013 09:54:59 +0000
Subject: [Rd] ggplot2: Add '+' operator for aes (uneval) objects
Message-ID: <EDB44DA865211646A192A94DF3C6FA670F72EC53@DEMDCE0057.nestle.com>

Dear all,

Is there a reason, why there is no +-operator for aes (i.e. uneval) objects (as there is for themes and gg objects)? I had a couple of cases where such an operator would be useful, for instance to combine the result of aes and aes_string in functions. Any flaws with the following proposition:

 `+.uneval` <- function(e1, e2) {
  dup <- names(e1) %in% names(e2)
  if (any(dup)) {
    duplist <- paste(sQuote(names(e1)[dup]), collapse = ", ")
    msg <- sprintf(ngettext(length(dup),
                   "element %s occurs in both summands - second one gets precedence",
                   "elements %s occur in both summands - second one gets precedence"),
                   duplist)
    warning(msg, domain = NA)
  }
  res <- c(e1[!dup], e2)
  class(res) <- "uneval"
  res
}

Any thoughts on that?

Kind Regards,

Thorn Thaler 
NRC Lausanne
Applied Mathematics



[Rd] ggplot2: Add '+' operator for aes (uneval) objects
Thaler,Thorn,LAUSANNE,Applied Mathematics