s-news
[Top] [All Lists]

Re: Calling xyplot from inside a function.

To: Paul Lasky <phlasky@earthlink.net>, S-News <s-news@lists.biostat.wustl.edu>
Subject: Re: Calling xyplot from inside a function.
From: Thom Burnett <Thom.Burnett@cognigencorp.com>
Date: Tue, 04 Jul 2006 13:00:24 -0400
In-reply-to: <E1FxnUG-0005Nd-2s@elasmtp-kukur.atl.sa.earthlink.net>
References: <E1FxnUG-0005Nd-2s@elasmtp-kukur.atl.sa.earthlink.net>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915
I'm pretty sure that you need to wrap the xyplot() in print()
print(xyplot( den$y ~ den$x, xlab="Points", type = "l",main = main2, col = 1, ... ) )

I don't know the labeling you want off the top of my head. You might be able to do it with the axes() function or you may need to use text() but I think you know as much about them and using them in a panel function as I do.



Paul Lasky wrote:

I know this is another tiresome "scoping" question, but I can't seem to get a Trellis plot with panel functions to work when called from a function: What I want to do is graph prob density, put some quantile vertical lines on the graph, and place some text on the graph labeling the vertical lines; the following code (without attempting the labeling) doesn't work: myFunction = function( obj ) {
     #
     den = density( obj$score, n=100, width = 29 )
     quant = quantile( obj$score, c( 0.1, 0.5, 0.9 ) )
     main2 = "My Stuff"
     #
xyplot( den$y ~ den$x, xlab="Points", type = "l",main = main2, col = 1,
        panel = function(x, y) {
           panel.abline( v  = quant, lty = 2 )
        }
) } Also what is the code for Labeling the vertical quantile lines with text at the bottom such as " 10%", "Median", "90%"? A panel.text function isn't available. Producing this plot within a function is easy to do with the old-fashioned plot function. But Trellis plots seem to be so difficult to work with that, frankly, most of the time they aren't worth the effort. In this instance, however it would be desirable from a publication standpoint to produce a Trellis plot. Paul Lasky
P & B Consultants.


<Prev in Thread] Current Thread [Next in Thread>