Description Arguments Details Examples
Versatile function to remove objects.
save.objects |
an optional list naming objects to be saved (i.e., not to be removed). |
save.patterns |
an optional list of string patterns or regular expressions which specifies the objects to be saved (i.e., not to be removed) . |
rm.objects |
a list naming objects to be removed. |
rm.patterns |
an optional list of string patterns or regular expressions which specifies the objects to be removed. |
modes |
a list to set the type or storage mode of the save.patterns and/or rm.patterns. For example "logical", "integer", "double", "complex", "raw", "character", "list", "expression", "name", "symbol" and "function". |
envir |
the environment to use. Default is set to .GlobalEnv |
inherits |
should the enclosing frames of the environment be inspected? |
The traditional rm function from base is not a
versatile function because it cannot handle exceptional objects or
string patterns to skip or remove. Moreover, rm gives no
warning before removing the objects and is not interactive. Also,
the pattern argument of ls function cannot
handle multiple patterns or multiple
regular expressions. This function has been
developed for sake of versatility, where you can determine
exceptional objects and patterns for saving and/or removing objects.
Also, you receive proper message regarding the final approval of
removing objects. The search strategy of rm_versatile
is
based upon apropos function, which
enables you to determine the type or storage mode of the objects
(e.g., double, integer, character, etc.).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # First let us making some objects
a <- 1
b <- "female"
c <- FALSE
d <- 4:10
e <- 5
f <- 6
g <- 7
df1 <- 8
df2 <- 9
dfcol <- 10
dff1 <- 11
dfff3 <- 12
mydata1 <- 13
mymydata <- 14
dataframe1 <- data.frame(
gender = c("F", "M", "M", "F"),
score = c(10, 12, 14, 18)
)
matrix.a <- matrix(1:10, nrow = 2, ncol = 5)
matrix2 <- matrix(1:100, ncol = 2)
x <- c("a", "b", "c", "d")
y <- c("d", "e", "f")
# Remove objects by rm.versatile
rm_versatile(
save.objects = list("a", "b", "c"),
save.patterns = list("df", "data"),
rm.objects = list("x", "y"),
rm.patterns = list("matrix")
)
# List objects
ls()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.