askrm: Interactive application of selected function a list of objects.
Description
This function was originally written to do the same as the unix rm -i command. The user supplies a list of items and the name of a function which is optionally applied to each item in turn.
Echo back the input function, for archival reference.
selected
All the items from the input list to which the function fn was applied. In the default case, these are the items deleted from the environment.
evout
A list of the value(s) returned by the function, if any, each time it was executed.
Arguments
items
A character vector of names of the objects to be acted upon (such as ls() returns). The default is all objects in the parent working environment.
fn
The name of the function to be applied, supplied as a character string. Possible future upgrades may allow function names to be entered without quotes.
ask
If TRUE , the user is prompted for "y/n" before performing the function on each object in the list. Be cautious about setting to FALSE for obvious reasons. Note that the only accepted positive response is exactly "y" so, e.g. "yes" will be treated as "no."
# get rid of junky objects left around from testingfoo<-1afoo<-c(foo,2)
foob <- c('a','b','d')
askrm(ls(pattern="foo") )
x<- rep(1,10)
y<- runif(10)
askrm(c('x','y'),'sd',ask=FALSE)