Skip to content

Instantly share code, notes, and snippets.

@MyKo101
Last active September 2, 2021 20:42
Show Gist options
  • Select an option

  • Save MyKo101/19b57e3cb9fba08d56cdd6ffc8bb088f to your computer and use it in GitHub Desktop.

Select an option

Save MyKo101/19b57e3cb9fba08d56cdd6ffc8bb088f to your computer and use it in GitHub Desktop.
Load Folder as Environment
temp_env <- new.env() #Create a new environment
if("LoadedEnv" %in% search()) detach("LoadedEnv") #If this has previously been run, remove it!
ff <- list.files("functions",full.names=TRUE) #Load up the files in the functions folder
silencer <- lapply(ff,source,local=temp_env) #source them all into the temporary environment
attach(temp_env,name="LoadedEnv") #Add the environment to the search path
rm(temp_env,ff,silencer) #Clean up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment