[R] Automate running files in R
Serena De Stefani
@eren@de@tef@ni @ending from gm@il@com
Sun Jul 22 22:26:58 CEST 2018
I need to automate a process in R. Basically I have a an R script (I will
call it R1) that needs three separate files to run. These three files are
the results output of one trial in my study.
So from each run in R I obtain the summary results for one trial, in a csv
file, plus 32 graphs for each decision point in the trial.
One subject goes through of nine trials. I was thinking about putting all
the files generated by one subject in one big folder, so I will have 27
files (three files times nine trials). This way I won't have to change
working directory multiple times (I wonder if there is a way to have R open
a folder with a certain name as directory, run a scripts, move the
directory to the next folder, run the script again...)
The trials are specified by the labels: AA AB AM BA BB BM MA MB MM. So for
subject 1, trial 1, I will have three files with the ending
For subject one, trial 2, R should choose the three files with the ending …
mov1_AB and so on.
At each run, R should save the csv summary output in a folder called
“summary_mov1” and name the files summary_mov1_AA, summary_mov1_AB etc. R
should save the 32 graphs in a different folder, named mov1_graphs,
graph1_mov1_AA, graph1_mov1_AB and so on (ideally, at this point another R
script (R2) should take these nine csv files and build some graphs out of
Once R has run R1 script nine times, I would proceed to a new subject.
So basically: use R1 with three mov1 files, get a summary csv file in a
summary folder (plus 32 graphs in a different folder).
Do this nine times. Once one get the nine csv summary files in the same
folder, use R2 to average them and build a graph.
Then do this for each subject (right now I have 7).
I have never done this type of automation so I am a bit lost. Any
suggestions? Any examples you can point me to? Which would be the best
workflow? At which level should I automate and which things should I rather
do by hand?
[[alternative HTML version deleted]]
More information about the R-help