Skip to content
Prev 69682 / 398528 Next

Lattice plot within a "for" loop does not happen?

On Friday 13 May 2005 09:24 am, Barry Rowlingson wrote:
As well as the much much shorter help(Lattice), which has: 

Note:

     High level Lattice functions (like 'xyplot') are different from
     conventional S graphics functions because they don't actually draw
     anything. Instead, they return an object of class ``trellis''
     which has to be then 'print'ed. This often causes confusion when
     the high level functions are called inside another function (most
     often 'source') and hence don't produce any output.

This page is pointed to from every conceivable place, including the 
Description, which says:

Description:   Implementation of Trellis Graphics. See ?Lattice for a
               brief introduction
No comments on that :)

However, let's say I want to use pseudo-random numbers to study the behaviour 
of sample correlation in uncorrelated observations. To this end, I do:
[1] 0.3899596

I do it a few more times:
[1] 0.6481215
[1] -0.02100718
[1] -0.01141006

but then I get tired and try:
+   cor(rnorm(10), rnorm(10))
+ }
resulting in nothing!!! 

Strange how no one ever (or at least any more) complains about this behavour, 
which should be exactly as ``confusing''. 

The upshot, of course, can be summarized by a now famous observation made 
slightly more than a decade ago:

http://groups-beta.google.com/group/comp.sys.next.advocacy/msg/92532d5651e795dc

Deepayan