Description Usage Arguments Details Value
This function has the same effect as the combination
suppressWarnings
and rm
, but it's not just a wrapper
for these functions. The problem is that for such a wrapper to
work, all the arguments to this functions would have to be given as
characters - in conflict with the desire for a solution where we
simply can replace rm
with kill
. This function thus
inspects it's call first, and tweaks it a bit in order to figure
out what to do in order to perform the extirpation. Note that this
function mainly is intended for the internal cleanup inside of
functions - and that the arguments thus have been made less general
than those of rm
, i.e. the arguments pos
and
inherits
are not present here.
1 | kill(..., list = character(), env = sys.parent())
|
... |
The objects to be removed, as names (unquoted) or character strings (quoted). Other stuff can be added, but will be ignored. |
list |
A character vector naming objects to be removed, or a
list of symbols. The default value for this argument is
|
env |
The environment to use, no default value is given -
but it will select the environment from which |
The "keep it tidy"-rule is useful when writing longer
functions, as it later on might be easier to update the
function at some point if only the objects needed for the
remaining part of the computation is presented - and the
removal of objects as soon as they no longer are needed also
have the beneficial effect of freeing up memory. rm
is
of course the natural option to use here, but since some
objects only exist under conditional statements (e.g. stuff
defined inside of a if
-else
construction), it
might once in a while happen that warnings about objects not
found will be triggered from rm
. This can be suppressed
by using suppressWarnings
, but that
"clutters up the code", so that's the reason for the existence
of this function.
This function will remove objects from the specified
environment, without triggering any warnings for those objects
that did not exist in the environment. Errors will be returned
if envir
fails to be an environment, or if list
doesn't
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.