Run R Scripts in Programs: Methods
To execute commands within an R language program, you can use the source() function to run another R script file. For example, if you have a script file named my_script.R, you can run it within an R program like this:
source("my_script.R")
You can load and execute commands from the my_script.R file. Additionally, you can also enter commands directly into the R console to perform specific tasks.