Browse Source

List and print environments

master
Maxime Wack 3 years ago
parent
commit
94a0f301e7
1 changed files with 41 additions and 0 deletions
  1. +41
    -0
      functions.Rmd

+ 41
- 0
functions.Rmd View File

@@ -24,6 +24,27 @@ print_package <- function(pkg)
}
```

### Environment

```{r print environment}
##' Print an environment
##'
##' Display the fullname of the environment,
##' the type, and the name with the size.
##' @title Print an environment
##' @param env The environment to print
##' @return The line to print to the buffer
print_environment <- function(env)
{
paste0(env,
"|env| ",
env,
" (",
length(objects(env)),
")")
}
```

# List objects

## Packages
@@ -42,3 +63,23 @@ list_packages <- function()
USE.NAMES = F,
simplify = T)
```
## Environments

### List environments

```{r list environments}
##' List environments
##'
##' List environments as returned by `search()`,
##' but ommiting `ESSR` from ESS, and the `Autoloads`
##' @title List environments
##' @return A character vector of environments
list_environments <- function()
{
sapply(setdiff(search(), c("ESSR", "Autoloads")),
print_environment,
USE.NAMES = F,
simplify = T)
}
```


Loading…
Cancel
Save