I use R in batch mode from command line to create several plots. As a first parameter I pass the input file name with the data sets. A second parameter holds a path to plot the result to. As a third parameter I want to pass the label name for the y-axis (ylab). Here comes my problem: The code below uses only the " and the first word within the third parameter as a y-axis label.
#! /usr/bin/env Rscript
library("igraph")
library("Rlab") # For xline command
args <- commandArgs(TRUE)
similarities <- scan(args[1])
similarities <- as.numeric(similarities)
# Open up a new pdf file for output given as cmd-line argument 2
pdf(args[2])
plot(similarities, xlab="Depth", type="l", col="red", ylab=args[3])
dev.off()
q()
Calling this script with the following command:
Script.r input.txt plot.pdf "Some y-axis label"
Produces a plot as shown in the following figure
When I change the line for the plot command to:
plot(similarities, xlab="Depth", type="l", col="red", ylab="Some y-axis label")
everything works as expected.