I tried to pass a number on a command line to a very simple R script to do some plotting.
I got this plot.r file:
args<-commandArgs(TRUE)
vmcn<-as.integer(args[1])
library(ggplot2)
library(grid)
file<-read.table("my file.txt",header=F)
ggplot(file,aes(x=V1))+geom_histogram(binwidth=1,aes(y=..count../vmcn*100))+theme_bw()
ggsave(filename="myfile.pdf",width=4,height=4)
When I run it this way:
Rscript plot.r 5000
I got the error:
Error in eval(expr, envir, enclos) : object 'vmcn' not found
Calls: print ... <Anonymous> -> as.data.frame -> lapply -> FUN -> eval
Execution halted
Can someone enlighten me on what's wrong?