I am using R, and I have a vector storing the names of files in a directory:
file_list <- c("loc1","loc2", ...)
I also have a list, storing dataframes of information for each of these locations, eg.
head(flist[[1]])
x y1 y2 y3 y4
1 0.01000 0.1208 0.02161 0.00179 0.0002174
1232 0.03333 0.2250 0.09075 0.01507 0.0029956
45 0.05000 0.2868 0.14409 0.02998 0.0069587
1708 0.06667 0.3429 0.19718 0.04795 0.0123678
1842 0.07500 0.3690 0.22315 0.05776 0.0155406
15 0.10000 0.4407 0.29743 0.08934 0.0265723
(The indices of the file names have the corresponding indices of elements in flist)
Each file information may be compared to some other files, but not all of them. So I created 4 groups:
g1 = "loc5"
g2 = c("loc1","loc4","loc10")
...
etc.
I would like to plot x vs. y4 for "loc1", "loc4", and "loc10" on one plot, x vs. y3 for "loc2"and "loc9" on another plot, etc.
However, I cannot seem to find anything less cumbersome than a for loop going through the file list, and assigning a number of embedded 'ifs' to test for each individual file name.
I would like to know if there is for example, a way to automatically create four empty plots (or subplots) then call the plot command on the appropriate one based on the file name (eg. file_list[i]).
Or any other efficient way to do this is welcome!