[R] Automate running files in R

Rich Shepard r@hep@rd @end|ng |rom @pp|-eco@y@@com
Mon Jul 23 00:40:23 CEST 2018

On Sun, 22 Jul 2018, Serena De Stefani wrote:

> 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.

> 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
> …mov1_AA
> For subject one, trial 2, R should choose the three files with the ending …
> mov1_AB and so on.


   In addition to Jim's advice about your directory structure you should
seriously consider your file naming convention. Just like variable names in
a program, you're almost guaranteed to not remember what each two-character
name means within six months of creating them. Spend a little more time
typing and use descriptive names ... and think of using a .dat extension and
using read.table(*.dat).

   You can name your files, for example, input_1.R, input_2.R, and input_3.R
for your run sources. And, for (e.g.,) subject 1, trial 1, name the file
sub1_trial1. This might produce output called sub1_trial1_input1,
sub1_trial1_input2, and sub1_trial1_input3.

   Now when you look at data.frames or output you and everyone else will know
just what each contains.

Have fun,


More information about the R-help mailing list