I am having a problem combining makefile and R program which accepts command line arguments.
An example: I have written an R file that accepts a command line argument and generates a plot.
Code
args <- commandArgs(trailingOnly=TRUE)
if (length(args) != 1) {
cat("You must supply only one number\n")
quit()
}
inputnumber <- args[1]
pdf("Rplot.pdf")
plot(1:inputnumber,type="l")
dev.off()
Makefile
all : make Rplot.pdf
Rplot.pdf : test.R
cat test.R | R --slave --args 10
Now the question is how to supply --args (10 in this case), so that I can say something like this:
make Rplot.pdf -10
I understand its more a Makefile
question rather an R
question.