scott smith
unread,Oct 15, 2012, 9:43:05 AM10/15/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ggp...@googlegroups.com
Hi,
I'm trying to write a simple .R script to produce plots from a .csv file specified in the command line.
for example, the following will plot LSS vs RSS from the scott_dose.csv file:
scott.smith@cougar:/home/scott.smith {31} Rscript Rtest.R scott_dose.csv LSS RSS
and the .R script is:
library(ggplot2)
args <- commandArgs(TRUE)
data<-data.frame(read.csv(args[1]))
attach(data)
x <- args[1]
y <- args[2]
z <- args[3]
x
y
z
qplot(y,z)
ggsave("~/tmp/RTest.png")
browseURL("~/tmp/RTest.png")
which produces a graph output, but with no data plotted:
scott.smith@cougar:/home/scott.smith {31} Rscript Rtest.R scott_dose.csv LSS RSS
Loading required package: methods
[1] "scott_dose.csv"
[1] "LSS"
[1] "RSS"
Saving 7 x 7 in image
Basically my "y" and "z" variables from commandArgs aren't being picked up by qplot. I'm sure it is something very simple, but I'm a relative beginner to R.
thanks, Scott