Learn R Programming

CHNOSZ (version 0.9-1)

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(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
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 generat 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 > 100 and package parallel is loaded, 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

palply is used in read.fasta and grep.file, count.aa and protein.length, affinity when the iprotein argument is given, equil.boltzmann and equil.reaction, and in revisit.

Examples

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

msgout("h3llo w0rld
")

Run the code above in your browser using DataLab