I want to run several R files using make. I have the following problems: 
- The output files are not saved in the corresponding folders. I tried using cdbut it didn't work.
- I cannot create the pdf plots, the plots.R file doesn't run with my - makefile. I only get:- Rscript src/example.R [Finished in 0.7s]
- I would like to load the data in the plot file only using - load("data.Rdata"). For that, I should set the directory first, and then run the code, right?
- Do I have to load all the libraries I will use in each R file?
Makefile
RDIR = ./src
TDATA = ./output/transform_data
PLOTDIR = ./output/figures
$(TDATA)/data.Rdata : $(RDIR)/example.R
    Rscript $<
$(PLOTDIR)/%.pdf : $(RDIR)/plots.R $(TDATA)/data.Rdata
    Rscript $<
Example:
dat <- data.frame(a = rnorm(20), b = rnorm(20))
save(dat, file = "output/transform_data/data.Rdata")
Plot:
load("output/tranform_data/data.Rdata")
pdf("output/figures/a.pdf")
print(plot(dat$a))
dev.off()
pdf("output/figures/b.pdf")
print(plot(dat$b))
dev.off()
