Description Usage Arguments Details Value Author(s) See Also Examples
These functions work through part or all of a workspace (task) hierarchy set up via cd
. cdfind
searches for objects through the (attached and unattached) task hierarchy. cdtree
displays the hierarchy structure. cd.change.all.paths
is useful for moving or migrating all or part of the hierarchy to new disk directories. cd.write.mvb.tasks
sets up sourceable text representations of the hierarchy, as a safeguard. cditerate
is the engine that crawls through the hierarchy, underpinning the others; you can write your own functions to be called by cditerate
.
If a task folder or its ".RData" file doesn't exist, a warning is given and (obviously) it's not iterated over. If that file does exist but there's a problem while loading it (e.g. a reference to the namespace of a package that can't be loaded– search for partial.namespaces
in mvbutils.packaging.tools
) then the iteration is still attempted, because something might be loaded. Neither case should cause an error.
1 2 3 4 5 6 7 8 | cdfind( pattern, from = ., from.text, show.task.name=FALSE)
cdregexpr( regexp, from = ., from.text, ..., show.task.name=FALSE)
cdtree( from = ., from.text = substitute(from), charlim = 90)
cd.change.all.paths( from.text = "0", old.path, new.path)
cd.write.mvb.tasks( from = ., from.text = substitute(from))
cditerate( from.text, what.to.do, so.far = vector("NULL", 0), ..., show.task.name=FALSE)
## S3 method for class 'cdtree'
plot( x, ...) # S3 method for cdtree; normally plot( cdtree(<<args>>))
|
pattern |
regexpr to be checked against object names. |
regexp |
regexpr to be checked against function source code. |
from |
unquoted path specifier (see |
from.text |
use this in place of |
show.task.name |
(boolean) as-it-happens display of which task is being looked at |
charlim |
maximum characters per line allowed in graphical display of |
old.path |
regexpr showing portion of directory names to be replaced |
new.path |
replacement portion of directory names |
what.to.do |
function to be called on each task (see Details) |
so.far |
starting value for accumulated list of function results |
... |
further fixed arguments to be passed to |
x |
result of a call to |
All these functions start by default from the task that is currently top of the search list, and only look further down the hiearchy (i.e. to unattached descendents). To make them work through the whole hierarchy, supply 0
as the from
argument. cdtree
has a plot
method, useful for complicated task hierarchies.
If you want to automatically crawl through the task hierarchy to do something else, you can write a wrapper function which calls cditerate
, and an inner function to be passed as the what.to.do
argument to cditerate
. The wrapper function will typically be very short; see the code of cdfind
for an example.
The inner function (typically called cdsomething.guts
) must have arguments found
, task.dir
, task.name
, and env
, and may have any other arguments, which will be set according as the ...
argument of cditerate
. found
accumulates the results of previous calls to what.to.do
. Your inner function can augment found
, and should return the (possibly augmented) found
. As for the other parameters: task.dir
is obvious; task.name
is a character(1) giving the full path specifier, e.g. "ROOT/mytask"
; and env
holds the environment into which the task has been (temporarily) loaded. env
allows you to examine the task; for instance, you can check objects in the task by calling ls(env=env)
inside your what.to.do
function. See the code of cdfind.guts
for an example.
cdfind
returns a list with one element for each object that is found somewhere; each such element is a character vector showing the tasks where the object was found.
cdregexpr
returns a list with one element for each task where a function whose source matches the regexpr is found; the names of each list element names the functions within that task (an ugly way to return results, for sure).
cdtree
returns an object of class cdtree
, which is normally printed with indentations to show the hierarchy. You can also plot(cdtree(...))
to see a graphical display.
cd.change.all.paths
and cd.write.mvb.tasks
do not return anything useful.
Mark Bravington
1 | cdfind( ".First", 0) # probably returns list( .First="ROOT")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.