[R] scripting qqplot and qqnorm

Vihan Pandey vihanpandey at gmail.com
Mon Jul 25 07:11:50 CEST 2011


Hi all,

I am an R newbie, and I have a question about scripting. I have the
following lines which I want to put int\
o a script which I can call from the shell of a Mac/Linux machine :

myrns <- read.csv(file="/Users/vihan/test.csv",sep="",header=FALSE)
qqnorm(myrns)
qqline(myrns)

This works fine on an interactive R session.

However, as I understand the basic framework of an R script for
executing on the shell to get a pdf output it is something like :

#!/usr/bin/Rscript

… list inputs…

pdf("plotexample.pdf", width=7, height=9)

plot(...)

dev.off()

print(paste("Plot was saved in:", getwd()))


therefore, I do :


#!/usr/bin/Rscript

myrns <- read.csv(file="/Users/vihan/test.csv",sep="",header=FALSE)
qqnorm(myrns)

dev.off()

print(paste("Plot was saved in:", getwd()))

but it does not work, the pdf generated is something my pdf viewer
cannot understand, plot(qqnorm(myrns)) and plot(qqline(myrns)) don't
work either.

Any ideas on what I'm doing wrong?

Moreover, would it be possible to have both qqline(myrns) and
qqnorm(myrns) on the same pdf?

Cheers!

- vihan



More information about the R-help mailing list