R Under development (unstable) (2023-11-16 r85542 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 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. 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. > library("R.utils") Loading required package: R.oo Loading required package: R.methodsS3 R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help. R.oo v1.25.0 (2022-06-12 02:20:02 UTC) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object is masked from 'package:R.methodsS3': throw The following objects are masked from 'package:methods': getClasses, getMethods The following objects are masked from 'package:base': attach, detach, load, save R.utils v2.12.3 successfully loaded. See ?R.utils for help. Attaching package: 'R.utils' The following object is masked from 'package:utils': timestamp The following objects are masked from 'package:base': cat, commandArgs, getOption, isOpen, nullfile, parse, warnings > > verbose <- Verbose(threshold=-1) > print(verbose) [1] "Verbose: isOn()=TRUE,\n threshold=-1, timestamp=FALSE, timestampFormat=%Y%m%d %H:%M:%S|" > > header(verbose, "A verbose writer example", padding=0) --------------------------------------------------------------------------- - A verbose writer example --------------------------------------------------------------------------- > > enter(verbose, "Analysis A") Analysis A... > for (kk in 1:10) { + printf(verbose, "step %d\n", kk) + if (kk == 2) { + cat(verbose, "Turning ON automatic timestamps") + timestampOn(verbose) + } else if (kk == 4) { + timestampOff(verbose) + cat(verbose, "Turned OFF automatic timestamps") + cat(verbose, "Turning OFF verbose messages for steps ", kk, "-6") + off(verbose) + } else if (kk == 6) { + on(verbose) + cat(verbose, "Turned ON verbose messages just before step ", kk+1) + } + + if (kk %in% c(5,8)) { + enterf(verbose, "Sub analysis #%d", kk) + for (jj in c("i", "ii", "iii")) { + cat(verbose, "part ", jj) + } + exit(verbose) + } + } step 1 step 2 Turning ON automatic timestamps 20231117 08:48:07| step 3 20231117 08:48:07| step 4 Turned OFF automatic timestamps Turning OFF verbose messages for steps 4-6 Turned ON verbose messages just before step 7 step 7 step 8 Sub analysis #8... part i part ii part iii Sub analysis #8...done step 9 step 10 > cat(verbose, "All steps completed!") All steps completed! > exit(verbose) Analysis A...done > > ruler(verbose) --------------------------------------------------------------------------- > cat(verbose, "Demo of some other methods:") Demo of some other methods: > str(verbose, c(a=1, b=2, c=3)) Named num [1:3] 1 2 3 - attr(*, "names")= chr [1:3] "a" "b" "c" > print(verbose, c(a=1, b=2, c=3)) a b c 1 2 3 > summary(verbose, c(a=1, b=2, c=3)) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.0 1.5 2.0 2.0 2.5 3.0 > evaluate(verbose, rnorm, n=3, mean=2, sd=3) [1] 6.494677 2.983581 -2.333283 > > ruler(verbose) --------------------------------------------------------------------------- > newline(verbose) > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # Odds and ends > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > print(equals(verbose, verbose)) [1] TRUE > print(equals(verbose, NA)) [1] FALSE attr(,"reason") [1] "Not same class" > setThreshold(verbose, -4) > print(verbose) [1] "Verbose: isOn()=TRUE,\n threshold=-4, timestamp=FALSE, timestampFormat=%Y%m%d %H:%M:%S|" > setDefaultLevel(verbose, -1) > print(verbose) [1] "Verbose: isOn()=TRUE,\n threshold=-4, timestamp=FALSE, timestampFormat=%Y%m%d %H:%M:%S|" > print(as.logical(verbose)) [1] TRUE > print(as.double(verbose)) [1] -4 > print(less(verbose)) [1] "Verbose: isOn()=TRUE,\n threshold=-3, timestamp=FALSE, timestampFormat=%Y%m%d %H:%M:%S|" > print(more(verbose)) [1] "Verbose: isOn()=TRUE,\n threshold=-5, timestamp=FALSE, timestampFormat=%Y%m%d %H:%M:%S|" > timestamp(verbose) 20231117 08:48:07| > setTimestampFormat(verbose) > print(getTimestampFormat(verbose)) [1] "%Y%m%d %H:%M:%S|" > warning("Hello world!") Warning message: Hello world! > warnings(verbose) Warnings detected: Warning message: Hello world! Warning message: 'warnings.Verbose' is deprecated. Use 'printWarnings()' instead. See help("Deprecated") and help("R.utils-deprecated"). > > print(timestamp()) ##------ Fri Nov 17 08:48:07 2023 ------## [1] "##------ Fri Nov 17 08:48:07 2023 ------##" > > > proc.time() user system elapsed 0.32 0.06 0.37