[R] Automate running files in R

Michael Friendly |r|end|y @end|ng |rom yorku@c@
Mon Jul 23 21:41:28 CEST 2018


Hi Serena

I'll add one more "in addition" to this list of suggestions. It may not 
be what you were thinking of, but may be far simpler in the long run.

The complexity of your approach comes from having separate data files 
for each subject and trial, for which you have to have a convention for
naming files and organizing them into coherently named directories.

The ideal solution would be to write your data into a single file, in 
which subjects and trials would just be separate columns.  More 
generally, anything you can do to change separate files into 
lines/records in a data frame will ease your task.

-Michael

On 7/22/18 6:40 PM, Rich Shepard wrote:
> 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.
> 
> Serena,
> 
>    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,
> 
> Rich
>




More information about the R-help mailing list