[S] calls to trellis in functions with varaible args

ecm@skew2.kellogg.nwu.edu
Thu, 18 Jun 1998 10:50:06 -0500 (CDT)


I use Splus version 3.4 under HP-UX 9.0.5

I would like to call trellis functions from within a function and
pass arguments to the trellis function that I specify as arguments
to my function. Here's a simple example:

> plotit
function(mydata, filename)
{
trellis.device(postscript, file = filename)
print(bwplot(y ~ x, data = mydata))
dev.off()
}

When I run this I get an error message:
> plotit(ans, "tmp.ps")
Error in trellis.device(postscript, file = filenam..: Object
"filename" not
found
Dumped

If I use the postscript command it works fine:
> plotit2
function(mydata, filename)
{
postscript(file = filename)
print(bwplot(y ~ x, data = mydata))
dev.off()
}
> plotit2(ans, "tmp.ps")
Generated postscript file "tmp.ps".

What is going on here? How can I make this work? I have the same
problem if I try to pass something to the bwplot command, e.g.,
bwplot(y~x, data=mydata, subset=(z==1))
where z is an argument to my function, e.g., plotit.

Thank you,

Ed Malthouse
Assistant Professor
Integrated Marketing Communications Department
Northwestern University

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news