R Tips and Tricks

  • Execute R codes after exiting from a shell prompt. First write a R script file, say "myfile.R". Then type
    nohup R < myfile.R > myfile.out --vanilla &
    
  • Output graph to file:
    postscript(file="test.ps", paper="special", width=8, height=6, horizontal=T)
    pairs(xxx, cex=0.6)
    dev.off()
    
  • Evalue an expression use eval().
    ss = expression(sin(pi/2))
    eval(ss)
    
  • mar specifies a numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot.
    x = seq(-pi, pi, length=100)
    postscript("ex1.ps", paper="special", width=8, height=3)
    par(mfrow=c(1, 3))
    par(mar=c(4.5, 2.5, 1, 0.5))
    plot(x, sin(x))
    plot(x, sin(x))
    plot(x, sin(x))
    dev.off()
    

Back to Homepage