[Distr-commits] r604 - in branches/distr-2.2/pkg/startupmsg: . tests tests/Examples
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Oct 16 05:23:56 CEST 2009
Author: stamats
Date: 2009-10-16 05:23:56 +0200 (Fri, 16 Oct 2009)
New Revision: 604
Added:
branches/distr-2.2/pkg/startupmsg/tests/
branches/distr-2.2/pkg/startupmsg/tests/Examples/
branches/distr-2.2/pkg/startupmsg/tests/Examples/startupmsg-Ex.Rout.save
Log:
added *-Ex.Rout.save to new tests/Examples folder
Added: branches/distr-2.2/pkg/startupmsg/tests/Examples/startupmsg-Ex.Rout.save
===================================================================
--- branches/distr-2.2/pkg/startupmsg/tests/Examples/startupmsg-Ex.Rout.save (rev 0)
+++ branches/distr-2.2/pkg/startupmsg/tests/Examples/startupmsg-Ex.Rout.save 2009-10-16 03:23:56 UTC (rev 604)
@@ -0,0 +1,293 @@
+
+R version 2.10.0 beta (2009-10-15 r50107)
+Copyright (C) 2009 The R Foundation for Statistical Computing
+ISBN 3-900051-07-0
+
+R is free software and comes with ABSOLUTELY NO WARRANTY.
+You are welcome to redistribute it under certain conditions.
+Type 'license()' or 'licence()' for distribution details.
+
+ Natural language support but running in an English locale
+
+R is a collaborative project with many contributors.
+Type 'contributors()' for more information and
+'citation()' on how to cite R or R packages in publications.
+
+Type 'demo()' for some demos, 'help()' for on-line help, or
+'help.start()' for an HTML browser interface to help.
+Type 'q()' to quit R.
+
+> ### * <HEADER>
+> ###
+> attach(NULL, name = "CheckExEnv")
+> assign("nameEx",
++ local({
++ s <- "__{must remake R-ex/*.R}__"
++ function(new) {
++ if(!missing(new)) s <<- new else s
++ }
++ }),
++ pos = "CheckExEnv")
+> ## Add some hooks to label plot pages for base and grid graphics
+> assign("base_plot_hook",
++ function() {
++ pp <- par(c("mfg","mfcol","oma","mar"))
++ if(all(pp$mfg[1:2] == c(1, pp$mfcol[2]))) {
++ outer <- (oma4 <- pp$oma[4]) > 0; mar4 <- pp$mar[4]
++ mtext(sprintf("help(\"%s\")", nameEx()), side = 4,
++ line = if(outer)max(1, oma4 - 1) else min(1, mar4 - 1),
++ outer = outer, adj = 1, cex = .8, col = "orchid", las=3)
++ }
++ },
++ pos = "CheckExEnv")
+> assign("grid_plot_hook",
++ function() {
++ grid::pushViewport(grid::viewport(width=grid::unit(1, "npc") -
++ grid::unit(1, "lines"), x=0, just="left"))
++ grid::grid.text(sprintf("help(\"%s\")", nameEx()),
++ x=grid::unit(1, "npc") + grid::unit(0.5, "lines"),
++ y=grid::unit(0.8, "npc"), rot=90,
++ gp=grid::gpar(col="orchid"))
++ },
++ pos = "CheckExEnv")
+> setHook("plot.new", get("base_plot_hook", pos = "CheckExEnv"))
+> setHook("persp", get("base_plot_hook", pos = "CheckExEnv"))
+> setHook("grid.newpage", get("grid_plot_hook", pos = "CheckExEnv"))
+> assign("cleanEx",
++ function(env = .GlobalEnv) {
++ rm(list = ls(envir = env, all.names = TRUE), envir = env)
++ RNGkind("default", "default")
++ set.seed(1)
++ options(warn = 1)
++ .CheckExEnv <- as.environment("CheckExEnv")
++ delayedAssign("T", stop("T used instead of TRUE"),
++ assign.env = .CheckExEnv)
++ delayedAssign("F", stop("F used instead of FALSE"),
++ assign.env = .CheckExEnv)
++ sch <- search()
++ newitems <- sch[! sch %in% .oldSearch]
++ for(item in rev(newitems))
++ eval(substitute(detach(item), list(item=item)))
++ missitems <- .oldSearch[! .oldSearch %in% sch]
++ if(length(missitems))
++ warning("items ", paste(missitems, collapse=", "),
++ " have been removed from the search path")
++ },
++ pos = "CheckExEnv")
+> assign("ptime", proc.time(), pos = "CheckExEnv")
+> ## at least one package changes these via ps.options(), so do this
+> ## before loading the package.
+> ## Use postscript as incomplete files may be viewable, unlike PDF.
+> ## Choose a size that is close to on-screen devices, fix paper
+> grDevices::ps.options(width = 7, height = 7, paper = "a4", reset = TRUE)
+> grDevices::postscript("startupmsg-Ex.ps")
+>
+> assign("par.postscript", graphics::par(no.readonly = TRUE), pos = "CheckExEnv")
+> options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly"))
+> options(warn = 1)
+> library('startupmsg')
+:startupmsg> Utilities for start-up messages (version 0.7)
+:startupmsg>
+:startupmsg> For more information see ?"startupmsg",
+:startupmsg> NEWS("startupmsg")
+
+>
+> assign(".oldSearch", search(), pos = 'CheckExEnv')
+> assign(".oldNS", loadedNamespaces(), pos = 'CheckExEnv')
+> cleanEx(); nameEx("StartupUtilities")
+> ### * StartupUtilities
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: StartupUtilities
+> ### Title: Utilities for start-up messages
+> ### Aliases: startupmsg infoShow TOBEDONE NEWS readVersionInformation
+> ### readURLInformation pointertoNEWS StartupMessage startupPackage
+> ### startupType startupEndline startupMessage suppressStartupMessages
+> ### onlytypeStartupMessages
+> ### Keywords: utilities
+>
+> ### ** Examples
+>
+> ## a set of test messages
+> several.messages<-function() {
++ startupMessage("this is a type 'version' startup message", pkg="PKG")
++ startupMessage("this is a type 'information' startup message",
++ pkg="PKG", type="information")
++ message("this is an ordinary message")}
+>
+> ## issuing of messages with different wrappers
+> several.messages()
+this is a type 'version' startup message
+this is a type 'information' startup message
+this is an ordinary message
+> suppressStartupMessages(several.messages())
+this is an ordinary message
+> suppressMessages(several.messages())
+> onlytypeStartupMessages(several.messages(),atypes=c("version","notabene"))
+this is a type 'version' startup message
+
+this is an ordinary message
+>
+> ##Example by Seth Falcon:
+> ## Here is a test function
+> doit <- function() {
++ several.messages()
++ return(123)
++ }
+>
+> ## Here is an example message handler. Here, you could write messages
+> ## to a file, send them as email to your friends or enemies, etc.
+> ## For the example, we'll just prepend 'MSG:'
+> msgLogger <- function(m) {
++ types<-paste("(", startupType(m),"):", sep="")
++ cat(paste("MSG: ",types, conditionMessage(m)), "\n")
++ }
+>
+> ## Finally, call the doit function and customize how messages are
+> ## handled.
+> withCallingHandlers(doit(),
++ StartupMessage=function(m) {
++ invokeRestart("custom", m, msgLogger)
++ })
+MSG: (version): this is a type 'version' startup message
+
+MSG: (information): this is a type 'information' startup message
+
+this is an ordinary message
+[1] 123
+> ### reading information file utilities
+> readVersionInformation("stats")
+$ver
+[1] "2.10.0"
+
+$title
+[1] "The R Stats Package"
+
+> readURLInformation("stats")
+NULL
+> ## for packages with URL file see e.g. dse1
+> pointertoNEWS("stats") ## no NEWS file;
+NULL
+> NEWS("stats") ## no NEWS file;
+Cannot open file '/home/btms02/RTOP/Rbranch/library/stats/NEWS': No such file or directory
+
+> ## for packages with NEWS file see e.g. randomForest, distr
+>
+>
+>
+> cleanEx(); nameEx("myStartupUtilities")
+> ### * myStartupUtilities
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: myStartupUtilities
+> ### Title: Example functions to utilities for start-up messages
+> ### Aliases: mystartupMessage mySMHandler buildStartupMessage
+> ### Keywords: utilities
+>
+> ### ** Examples
+>
+> ## a set of test messages
+>
+> msg <- "Note that you may set global options by options() --- cf. ?\"options\"."
+>
+> ## issuing of messages controlled by options()
+> buildStartupMessage(pkg="stats", msg)
+:stats> The R Stats Package (version 2.10.0)
+:stats>
+:stats> Note that you may set global options by options() --- cf.
+:stats> ?"options".
+
+> suppressStartupMessages(buildStartupMessage(pkg="stats", msg) )
+> suppressMessages(buildStartupMessage(pkg="stats", msg))
+> onlytypeStartupMessages(buildStartupMessage(pkg="stats", msg),
++ atypes="version")
+The R Stats Package (version 2.10.0)
+
+>
+> getOption("StartupBanner")
+NULL
+> buildStartupMessage(pkg="stats", msg)
+:stats> The R Stats Package (version 2.10.0)
+:stats>
+:stats> Note that you may set global options by options() --- cf.
+:stats> ?"options".
+
+>
+> options("StartupBanner"="off");getOption("StartupBanner")
+[1] "off"
+> buildStartupMessage(pkg="stats", msg)
+>
+> options("StartupBanner"="complete");getOption("StartupBanner")
+[1] "complete"
+> buildStartupMessage(pkg="stats", msg)
+:stats> The R Stats Package (version 2.10.0)
+:stats>
+:stats> Note that you may set global options by options() --- cf.
+:stats> ?"options".
+
+>
+> options("StartupBanner"="something else");getOption("StartupBanner")
+[1] "something else"
+> buildStartupMessage(pkg="stats", msg)
+:stats> The R Stats Package (version 2.10.0)
+:stats>
+>
+> options("StartupBanner"=NULL);getOption("StartupBanner")
+NULL
+> buildStartupMessage(pkg="stats", msg)
+:stats> The R Stats Package (version 2.10.0)
+:stats>
+:stats> Note that you may set global options by options() --- cf.
+:stats> ?"options".
+
+>
+>
+> MNH <- "http://www.r-project.org/"
+> buildStartupMessage(pkg="stats", msg, packageHelp=TRUE, MANUAL=MNH)
+:stats> The R Stats Package (version 2.10.0)
+:stats>
+:stats> Note that you may set global options by options() --- cf.
+:stats> ?"options".
+:stats>
+:stats> For more information see ?"stats", as well as
+:stats> http://www.r-project.org/
+
+> ## not quite a manual, but to illustrate the principle:
+> ## "demo/nlm.R" as a "manual": to be system-independent the
+> ## first call is to be preferred
+> buildStartupMessage(pkg="stats", msg, packageHelp=TRUE, MANUAL=c("demo","nlm.R"))
+:stats> The R Stats Package (version 2.10.0)
+:stats>
+:stats> Note that you may set global options by options() --- cf.
+:stats> ?"options".
+:stats>
+:stats> For more information see ?"stats"
+
+> ### works, too, (i.e. is equivalent) under Linux and Windows (at least):
+> buildStartupMessage(pkg="stats", msg, packageHelp=TRUE, MANUAL="demo/nlm.R")
+:stats> The R Stats Package (version 2.10.0)
+:stats>
+:stats> Note that you may set global options by options() --- cf.
+:stats> ?"options".
+:stats>
+:stats> For more information see ?"stats"
+
+>
+>
+>
+>
+> ### * <FOOTER>
+> ###
+> cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
+Time elapsed: 0.108 0.008 0.123 0.004 0.004
+> grDevices::dev.off()
+null device
+ 1
+> ###
+> ### Local variables: ***
+> ### mode: outline-minor ***
+> ### outline-regexp: "\\(> \\)?### [*]+" ***
+> ### End: ***
+> quit('no')
More information about the Distr-commits
mailing list