Question: Essentially, I have constructed a sizable predictive model in R with about 10~15 separate script files for collecting, sorting, analyzing and presenting my data. Rather than just put everything into one gigantic script file, I would like to maintain some level of modularity and run each piece from a control script, or some kind of comparable control mechanism, as I've done in matlab before. Is this possible in R?

I have read this thread as well as its related threads, but couldn't find this exact answer.
[Organizing R Source Code](https://stackoverflow.com/q/2284446/761313)

Answer: 
You can source all `.R` scripts from a folder:

```
# Load tidyverse
library(tidyverse) # to pipe (%>%) and map across each file

# List files and source each
list.files("path_to_folder", full.names = TRUE) %>% map(source)

```

Here, you list all files from a folder, then you map across the `source()` function.

This solution is more useful if each script contains some functions, and you would then like to use these functions in a `master_script`.
Although I understand your need for modularity, why not simply create a single script for the run of interest. Sourcing multiple scripts results in complexities of not being able to pass variables across scripts unless you write to files (which wastes CPU cycles). You could even build a master script that would read the text contents of each script and then create the master script and then run that script.