If we need to access from the R script the file genome-yyy.fa
located in
data/sequences
:
| # Get the project top folder
TOP_DIR = system2("git", args = c("rev-parse", "--show-toplevel"), stdout = T)
# Build the path to the data file
DATA_DIR = file.path(TOP_DIR, "data/sequences")
DATA_FILE = file.path(DATA_DIR, "genome-yyy.fa")
# Build the path to the output file (results/plot.png)
PLOT_FILE = file.path(TOP_DIR, "results", "plot.png")
|
Again, the R script can now be moved anywhere within the project, it will be
able to access the data file and to write the plot file to the correct
location.