clear: [!] Clear variables from workspace (current environment)

Description Usage Arguments Details Author(s) See Also Examples

View source: R/clear-functions.R

Description

Remove items from the workspace, i.e. the current environment, and free up system memory. Explanation in section "Details".

Usage

 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
33
34
35
36
clear(
  ...,
  list = NULL,
  except = NULL,
  all.names = FALSE,
  envir = parent.frame()
)

clear_all(
  ...,
  list = NULL,
  except = NULL,
  all.names = TRUE,
  envir = parent.frame()
)

clear_hidden_only(..., list = NULL, except = NULL, envir = parent.frame())

clear_all_except(..., list = NULL, all.names = FALSE, envir = parent.frame())

clear_class(
  clr_class = NULL,
  except_var = NULL,
  all.names = FALSE,
  envir = parent.frame()
)

clear_all_except_class(
  except_class = NULL,
  all.names = FALSE,
  envir = parent.frame()
)

clear_fun(all.names = TRUE, envir = parent.frame())

clear_except(...)

Arguments

...

The objects as names (unquoted) or character strings (quoted).

list

A character vector naming objects. Used instead of '...'. If list is not NULL, dots '...' are ignored.

except, except_var

Names of variables (as a character vector) to be kept (to be cleared). Default is NULL.

all.names

a logical value. If TRUE (default only in clear_all and clear_fun), all objects are cleared. If FALSE (default in clear), objects which names begin with a . are omitted.

envir

The environment in which function takes action. Default is the global environment .GlobalEnv.

clr_class

Names of classes (as a character vector). Objects of indicated classes to be removed.

except_class

Names of classes (as a character vector) that have not to be cleared. Default is NULL.

Details

clear removes either listed or, if none is listed, all* not hidden (that name does not begin with dot(.)) variables. Default is to clear all except hidden objects.

clear_all the same as clear just aditionally clears hidden variables (that name begins with dot (.)).

clear_except clears variables except listed ones.

clear_class removes objects of indicated class(es), except those which names provided in list except_var.

clear_all_except_class keeps objects of indicated class(es), others are cleared.

clear_fun removes all (including hidden) items that are functions.

These functions are wrappers and extensions for rm.

Author(s)

Vilmantas Gegzna

See Also

Remove objects from a specified environment rm, list objects ls.

Other spMisc utilities: bru(), clc(), fCap(), isFALSE(), list_AddRm(), make.filenames(), open_wd(), printDuration(), regexp2df(), st01()

Examples

 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
33
34
35
36
37
38
39
40
clear()

  A <- 5
  B <- "s"
 D1 <- "string2"
 D2 <- "string3"
  L <- list(A,B)
FUN <- function(x) x
`%in%` <- `%in%`


ls()

clear_class("numeric")
ls()

clear_fun()
ls()

clear(except = c("D1", "D2"))
ls()

clear(except = c("B"))
ls()

clear()
ls()

numeric_1 <- 5
numeric_2 <- 5
numeric_3 <- 5
My_list <- list("a","A")
My_string <- "ABC"
ls()

clear_all_except_class(c("numeric", "list"))
ls()

clear_class("numeric", except_var = "numeric_1")
ls()

GegznaV/spMisc documentation built on April 26, 2020, 5:59 p.m.