[Distr-commits] r989 - in branches/distr-2.6/pkg/distrMod: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 16 00:00:37 CET 2015


Author: ruckdeschel
Date: 2015-01-16 00:00:35 +0100 (Fri, 16 Jan 2015)
New Revision: 989

Modified:
   branches/distr-2.6/pkg/distrMod/R/AllPlot.R
   branches/distr-2.6/pkg/distrMod/R/qqplot.R
   branches/distr-2.6/pkg/distrMod/R/returnlevelplot.R
   branches/distr-2.6/pkg/distrMod/inst/NEWS
   branches/distr-2.6/pkg/distrMod/man/L2ParamFamily-class.Rd
   branches/distr-2.6/pkg/distrMod/man/qqplot.Rd
   branches/distr-2.6/pkg/distrMod/man/returnlevelplot.Rd
Log:
[distrMod] plot methods gain argument withSubst to control pattern substitution in titles and axis lables; qqplot and returnlevelplot now also offer pattern substitution

Modified: branches/distr-2.6/pkg/distrMod/R/AllPlot.R
===================================================================
--- branches/distr-2.6/pkg/distrMod/R/AllPlot.R	2015-01-15 22:55:02 UTC (rev 988)
+++ branches/distr-2.6/pkg/distrMod/R/AllPlot.R	2015-01-15 23:00:35 UTC (rev 989)
@@ -11,9 +11,18 @@
              main = FALSE, inner = TRUE, sub = FALSE, 
              col.inner = par("col.main"), cex.inner = 0.8, 
              bmar = par("mar")[1], tmar = par("mar")[3], ...,
-             mfColRow = TRUE, to.draw.arg = NULL){
+             mfColRow = TRUE, to.draw.arg = NULL, withSubst= TRUE){
 
         xc <- match.call(call = sys.call(sys.parent(1)))$x
+        xcc <- as.character(deparse(xc))
+       .mpresubs <- if(withSubst){
+                   function(inx) 
+                    .presubs(inx, c("%C", "%A", "%D" ),
+                          c(as.character(class(x)[1]), 
+                            as.character(date()), 
+                            xcc))
+               }else function(inx)inx
+    
         dots <- match.call(call = sys.call(sys.parent(1)), 
                        expand.dots = FALSE)$"..."
         
@@ -127,11 +136,6 @@
         subL <- FALSE
         lineT <- NA
 
-     .mpresubs <- function(inx)
-                    .presubs(inx, c("%C", "%D", "%A"),
-                          c(as.character(class(x)[1]),
-                            as.character(date()),
-                            as.character(deparse(xc))))
 
      if (hasArg(main)){
          mainL <- TRUE

Modified: branches/distr-2.6/pkg/distrMod/R/qqplot.R
===================================================================
--- branches/distr-2.6/pkg/distrMod/R/qqplot.R	2015-01-15 22:55:02 UTC (rev 988)
+++ branches/distr-2.6/pkg/distrMod/R/qqplot.R	2015-01-15 23:00:35 UTC (rev 989)
@@ -91,17 +91,27 @@
              legend.pref = "",     ## prefix for legend  text
              legend.postf = "",    ## postfix for legend text
              legend.alpha = alpha.CI, ## nominal level of CI
-             debug = FALSE ## shall additional debug output be printed out?
+             debug = FALSE, ## shall additional debug output be printed out?
+             withSubst = TRUE
     ){ ## return value as in stats::qqplot
 
     mc <- match.call(call = sys.call(sys.parent(1)))
-    if(missing(xlab)){ xlab <- mc$xlab <- as.character(deparse(mc$x))}
-    if(missing(ylab)){ ylab <- mc$ylab <- as.character(deparse(mc$y))}
+    xcc <- as.character(deparse(mc$x))
+    ycc <- as.character(deparse(mc$y))
+    if(missing(xlab)){ xlab <- mc$xlab <- xcc}
+    if(missing(ylab)){ ylab <- mc$ylab <- ycc}
     mcl <- as.list(mc)[-1]
     force(x)
     if(is.null(mcl$datax)) datax <- FALSE
     if(!datax){ mcl$ylab <- xlab; mcl$xlab <- ylab}
 
+   .mpresubs <- if(withSubst){
+                   function(inx) 
+                    .presubs(inx, c("%C", "%A", "%D" ),
+                          c(as.character(class(x)[1]), 
+                            as.character(date()), 
+                            xcc))
+               }else function(inx)inx
     xj <- x
     if(any(.isReplicated(x)))
        xj[.isReplicated(x)] <- jitter(x[.isReplicated(x)], factor=jit.fac)
@@ -161,6 +171,14 @@
     mcl$cex <- cex.pch
     mcl$col <- col.pch
 
+    mcl$xlab <- .mpresubs(mcl$xlab)
+    mcl$ylab <- .mpresubs(mcl$ylab)
+
+    if (!is.null(eval(mcl$main)))
+        mcl$main <- .mpresubs(eval(mcl$main))
+    if (!is.null(eval(mcl$sub)))
+        mcl$sub <- .mpresubs(eval(mcl$sub))
+
     if (!withSweave){
            devNew(width = width, height = height)
     }

Modified: branches/distr-2.6/pkg/distrMod/R/returnlevelplot.R
===================================================================
--- branches/distr-2.6/pkg/distrMod/R/returnlevelplot.R	2015-01-15 22:55:02 UTC (rev 988)
+++ branches/distr-2.6/pkg/distrMod/R/returnlevelplot.R	2015-01-15 23:00:35 UTC (rev 989)
@@ -66,11 +66,22 @@
              legend.pref = "",     ## prefix for legend  text
              legend.postf = "",    ## postfix for legend text
              legend.alpha = alpha.CI, ## nominal level of CI
-             debug = FALSE ## shall additional debug output be printed out?
+             debug = FALSE, ## shall additional debug output be printed out?
+             withSubst = TRUE
     ){ ## return value as in stats::qqplot
 
     MaxOrPOT <- match.arg(MaxOrPOT)
     mc <- match.call(call = sys.call(sys.parent(1)))
+    xcc <- as.character(deparse(mc$x))
+
+   .mpresubs <- if(withSubst){
+                   function(inx) 
+                    .presubs(inx, c("%C", "%A", "%D" ),
+                          c(as.character(class(x)[1]), 
+                            as.character(date()), 
+                            xcc))
+               }else function(inx)inx
+
     if(missing(xlab)) mc$xlab <- paste(gettext("Return level of"),
                                        as.character(deparse(mc$x)))
     if(missing(ylab)) mc$ylab <- gettext("Return period (years)")

Modified: branches/distr-2.6/pkg/distrMod/inst/NEWS
===================================================================
--- branches/distr-2.6/pkg/distrMod/inst/NEWS	2015-01-15 22:55:02 UTC (rev 988)
+++ branches/distr-2.6/pkg/distrMod/inst/NEWS	2015-01-15 23:00:35 UTC (rev 989)
@@ -17,6 +17,10 @@
 + arguments panel.first, panel.last for plot-methods can now be lists
 + introduced returnlevelplot, a generalization of the respective
   diagnostic plot facility of package ismev
++ qqplot and returnlevelplot gain pattern substitution like plot in 
+  titles and x/y axis lables
++ pattern substitution can now be switched on and off in all plot 
+  functions according to argument withSubst
   
 GENERAL ENHANCEMENTS:
 

Modified: branches/distr-2.6/pkg/distrMod/man/L2ParamFamily-class.Rd
===================================================================
--- branches/distr-2.6/pkg/distrMod/man/L2ParamFamily-class.Rd	2015-01-15 22:55:02 UTC (rev 988)
+++ branches/distr-2.6/pkg/distrMod/man/L2ParamFamily-class.Rd	2015-01-15 23:00:35 UTC (rev 989)
@@ -154,7 +154,7 @@
              main = FALSE, inner = TRUE, sub = FALSE, 
              col.inner = par("col.main"), cex.inner = 0.8, 
              bmar = par("mar")[1], tmar = par("mar")[3], ...,
-             mfColRow = TRUE, to.draw.arg = NULL)
+             mfColRow = TRUE, to.draw.arg = NULL, withSubst = TRUE)
       } where \describe{
         \item{x}{object of class \code{"L2ParamFamily"}}
         \item{withSweave}{logical: if \code{TRUE} (for working with \command{Sweave}) 
@@ -191,18 +191,28 @@
                          \code{dimnr} running through the number of rows of the 
                          trafo matrix.
                          }
+       \item{withSubst}{logical; if \code{TRUE} (default) pattern substitution for
+          titles and lables is used; otherwise no substitution is used. }
+
        \item{\dots}{addtional arguments for \code{plot} --- see 
                \code{\link[graphics]{plot}}, 
                \code{\link[graphics]{plot.default}}, 
                \code{\link[stats]{plot.stepfun}} }
 
       } 
-      if \code{\dots} contains argument \code{ylim}, this may either be
+      If \code{\dots} contains argument \code{ylim}, this may either be
       as in \code{plot.default} (i.e. a vector of length 2) or a vector of 
       length 4, where the first two elements are the values for \code{ylim} 
       in panels "d.c" and "d.d", and the last
       two elements are the values for \code{ylim} resp. \code{xlim} in panels 
       "p", "p.c", "p.d" and "q", "q.c", "q.d".
+      In all title and axis label arguments, if \code{withSubst} is \code{TRUE},
+      the following patterns are substituted:
+      \describe{
+         \item{\code{"\%C"}}{class of argument \code{x}}
+         \item{\code{"\%A"}}{deparsed argument \code{x}}
+         \item{\code{"\%D"}}{time/date-string when the plot was generated}
+      }
 
 In addition, argument \code{\dots} may contain arguments \code{panel.first},
 \code{panel.last}, i.e., hook expressions to be evaluated at the very beginning

Modified: branches/distr-2.6/pkg/distrMod/man/qqplot.Rd
===================================================================
--- branches/distr-2.6/pkg/distrMod/man/qqplot.Rd	2015-01-15 22:55:02 UTC (rev 988)
+++ branches/distr-2.6/pkg/distrMod/man/qqplot.Rd	2015-01-15 23:00:35 UTC (rev 989)
@@ -24,7 +24,7 @@
     with.legend = TRUE, legend.bg = "white",
     legend.pos = "topleft", legend.cex = 0.8, 
     legend.pref = "", legend.postf = "",  legend.alpha = alpha.CI,
-    debug = FALSE)
+    debug = FALSE, withSubst = TRUE)
 \S4method{qqplot}{ANY,ProbFamily}(x, y,
    n = length(x), withIdLine = TRUE, withConf = TRUE,
    withConf.pw  = withConf,  withConf.sim = withConf,
@@ -120,6 +120,8 @@
 \item{legend.postf}{character to be appended to legend text}
 \item{legend.alpha}{nominal coverage probability}
 \item{debug}{logical; if \code{TRUE} additional output to debug confidence bounds.}
+\item{withSubst}{logical; if \code{TRUE} (default) pattern substitution for
+      titles and axis lables is used; otherwise no substitution is used. }
 }
 \description{
   We generalize function \code{\link[stats:qqnorm]{qqplot}} from package \pkg{stats} to
@@ -131,7 +133,14 @@
    it can use an argument \code{ParamFamily} to conclude on the model
    distribution. Graphical parameters may be given as arguments to
    \code{qqplot}.
+  In all title and label arguments, if \code{withSubst} is \code{TRUE},
+  the following patterns are substituted:
+\describe{
+\item{\code{"\%C"}}{class of argument \code{x}}
+\item{\code{"\%A"}}{deparsed argument \code{x}}
+\item{\code{"\%D"}}{time/date-string when the plot was generated}
 }
+}
 \value{
     As for function \code{\link[stats:qqnorm]{qqplot}} from package \pkg{stats}: a
   list with components

Modified: branches/distr-2.6/pkg/distrMod/man/returnlevelplot.Rd
===================================================================
--- branches/distr-2.6/pkg/distrMod/man/returnlevelplot.Rd	2015-01-15 22:55:02 UTC (rev 988)
+++ branches/distr-2.6/pkg/distrMod/man/returnlevelplot.Rd	2015-01-15 23:00:35 UTC (rev 989)
@@ -27,7 +27,7 @@
     with.legend = TRUE, legend.bg = "white",
     legend.pos = "topleft", legend.cex = 0.8,
     legend.pref = "", legend.postf = "",  legend.alpha = alpha.CI,
-    debug = FALSE)
+    debug = FALSE, withSubst = TRUE)
 \S4method{returnlevelplot}{ANY,ProbFamily}(x, y,
    n = length(x), withIdLine = TRUE, withConf = TRUE,
    withConf.pw  = withConf,  withConf.sim = withConf,
@@ -133,6 +133,8 @@
 \item{legend.postf}{character to be appended to legend text}
 \item{legend.alpha}{nominal coverage probability}
 \item{debug}{logical; if \code{TRUE} additional output to debug confidence bounds.}
+\item{withSubst}{logical; if \code{TRUE} (default) pattern substitution for
+      titles and axis lables is used; otherwise no substitution is used. }
 }
 \description{
   We generalize the return level plot (which is one of the diagnostical
@@ -142,7 +144,15 @@
   \code{returnlevelplot} produces a rescaled QQ plot of data (argument \code{x}) 
   against a (model) distribution.
    Graphical parameters may be given as arguments to \code{returnlevelplot}.
+   In all title and label arguments, if \code{withSubst} is \code{TRUE},
+  the following patterns are substituted:
+\describe{
+\item{\code{"\%C"}}{class of argument \code{x}}
+\item{\code{"\%A"}}{deparsed argument \code{x}}
+\item{\code{"\%D"}}{time/date-string when the plot was generated}
 }
+
+}
 \value{
     As for function \code{\link[stats:qqnorm]{returnlevelplot}} from package \pkg{stats}: a
   list with components



More information about the Distr-commits mailing list