Last active
September 5, 2020 00:35
-
-
Save ctberthiaume/404974a3813cf026f0244a9fcb1df02e to your computer and use it in GitHub Desktop.
Find all object in basic RStudio search path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
recursive_ls <- function(envir=NULL, use_names=FALSE) { | |
# Base case | |
if (identical(envir, emptyenv())) { | |
return(list()) | |
} | |
if (is.null(envir)) { | |
envir <- parent.env(environment()) | |
} | |
if (!use_names) { | |
objs <- ls(envir) | |
} else { | |
objs <- names(envir) | |
} | |
envobjects <- recursive_ls(parent.env(envir), use_names) | |
envobjects[[length(envobjects)+1]] <- objs | |
names(envobjects)[length(envobjects)] <- environmentName(envir) | |
return(envobjects) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment