[R] sourced plot commands not working

Gavin Simpson gavin.simpson at ucl.ac.uk
Wed Apr 8 16:13:14 CEST 2009


On Wed, 2009-04-08 at 10:05 -0400, SHANE MILLER, BLOOMBERG/ 731 LEXIN
wrote:
> I have source a script running with no errors that ends in these lines:
> ==============
> for (i in 2:3) win.graph()
> dev.set(2)
> levelplot(avg ~ procs * size, rrt, drape=T, colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10)))
> dev.set(3)
> levelplot(avg ~ procs * size, ort, drape=T, colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10)))
> =============
> The graphics devices windows appear, however, there is no graph
> and the background of each window is gray indicating no active
> graph.
> 
> However, if I copy and paste these commands from the script and
> enter them into the console, they run fine. why?

The plotting commands are lattice functions. These need to be printed to
produce the plotting side effect you want. When entered at the command
line printing is explicit. This doesn't happen when sourced.

This is a FAQ 7.22:


> 
> R 2.8.1 2008-12-22 on windows.
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list