Learn R Programming

CHNOSZ (version 1.0.8)

util.program: Functions for Various Programming Tasks

Description

Get name of calling function; send messages to standard output; use multiple processors if parallel package is loaded.

Usage

caller.name(n) msgout(..., domain = NULL, appendLF = FALSE) palply(varlist, X, FUN, ...)

Arguments

n
numeric, number of frame to go up
...
equivalent to the same argument in message or parLapply
domain
equivalent to the same argument in message
appendLF
equivalent to the same argument in message
varlist
character, names of variables to export using clusterExport
X
vector, argument for lapply or parLapply
FUN
function, argument for lapply or parLapply

Details

caller.name returns the name of the calling function n frames up (i.e., for n equal to 2, the caller of the function that calls this one). If called interactively, returns character().

msgout is a variation of message in base R. It writes output to stdout instead of stderr and has a default setting of appendLF of FALSE. This function is used throughout CHNOSZ to generate informative messages, that will show up both in an interactive session and in Sweave output, but that are suppressed while running the test_that testing scripts to make it easier to watch their progress.

palply is a wrapper function to run parLapply if length of X > thermo$opt$paramin and multiple cores are available, otherwise it runs lapply. Note that parLapply is called with methods set to FALSE. If lots of package startup messages are created when running makeCluster (which is called by palply), it can probably be stopped by adding a test for interactive sessions around any library commands in the Rprofile.

See Also

read.fasta, count.aa, affinity, equil.boltzmann and equil.reaction for functions that use palply. Tests are in ‘tests/test-util.program.R’, and a “real life” application is in ‘demos/density.R’.

Examples

Run this code
caller.name()  # character(0)
afun <- function() caller.name()
afun()         # character(0)
bfun <- function() afun()
bfun()         # "bfun"

msgout("h3llo w0rld\n")

Run the code above in your browser using DataLab