env.clear_objects: Function for clearing all objects from cache in a session

Description Usage Details See Also Examples

Description

env.clear_objects

Usage

1
env.clear_objects(keep_pat = NULL, drop_pat = NULL)

Details

Working in an environment or in an app can mean the workspace or in-memory storage can get bogged down with unecessary data objects. This can impact speed or simply clutter the space itself. This function will remove all objects that are not functions in the current environment.

See Also

Other Environment utilities: env.clear_console

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# From a working environment
> sapply(ls(), function(i){
 is.function(get(i))
}) %>% {
  dput(names(.[!.]))
}

[1] "nf" "nf.raw" "nf.team_df" "nf.team_df_master" "nf.teams"

# Now clear anything beginning with nf followed by a dot and has a word after
# such as nf.team_df

> env.clear_objects(drop_pat = "nf\\.(\\w+)+$")

> sapply(ls(), function(i){
     is.function(get(i))
 }) %>% {
      (names(.[!.]))
 }

 [1] "nf"

CarlBoneri/roxydoc2 documentation built on Nov. 6, 2019, 8:01 a.m.