hklovs
hklovs

Reputation: 642

how to list all functions and values in global environment

I have a huge R project with 30+ functions and 30+ fixed values. Is there a smart way of exporting those functions into a list? I want to the entire function to be seen not just the syntax. The same goes for the values.

Best regards H

Upvotes: 1

Views: 700

Answers (2)

hklovs
hklovs

Reputation: 642

I used mget(lsf.str()), which solved my problem. Thanks

Upvotes: 1

user13653858
user13653858

Reputation:

If you want only a list of function and variable names, you just run ls():

# some stuff
a_fun <- function(x = 0) {return(x)}
b_var <- 1:5

# get only a vector of the names of your stuff
ls()
#> [1] "a_fun" "b_var"

If you want also to see the values and source codes of the functions, add mget():

# some stuff...
a_fun <- function(x = 0) {return(x)}
b_var <- 1:5

# get all the stuff as a list
mget(ls())
#> $a_fun
#> function(x = 0) {return(x)}
#> 
#> $b_var
#> [1] 1 2 3 4 5

Upvotes: 1

Related Questions