s-news
[Top] [All Lists]

Re: Using "arguments" of a function as part of a title for a

To: Savitri Appana <saviappana@yahoo.com>
Subject: Re: Using "arguments" of a function as part of a title for a
From: Sundar Dorai-Raj <sundar.dorai-raj@pdf.com>
Date: Fri, 28 Jan 2005 15:05:34 -0600
Cc: s-news@wubios.wustl.edu
In-reply-to: <20050128205306.14651.qmail@web51905.mail.yahoo.com>
Organization: PDF Solutions, Inc.
References: <20050128205306.14651.qmail@web51905.mail.yahoo.com>
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)


Savitri Appana wrote:
Hello S+ users,

I have to generate several plots so i created a simple
function which takes in as arguments "data", "x", and
"y" (see below).  Now i would like to be able to put
the actual "data" name as part of the subtitle (sub =
"data" ?).  How can i do this in S+ ?   Also, is it
possible to change the position of the subtitle (say
from 'bottom' to 'top' below the main title?

myPlot <- function(dat, x, y) {
        attach(dat)
        ## par(mfrow = c(3,2))
plot(x, y, main = "Smoothing splines", sub = ?????)
        lines(smooth.spline(x, y))
}
myPlot(myDat, hrs, pres)

final result:  a plot with a main title and sub title
as such:

"Smoothing splines" "myDat"
               [    plot       ]

:)

Any suggestions are much appreciated...
Thanks in advance,
Savi




I think you're looking for deparse(substitute(x)) and ?mtext:

 myPlot <- function(dat, x, y) {
        attach(dat)
        ## par(mfrow = c(3,2))
        plot(x, y, main = "Smoothing splines")
        mtext(text = deparse(substitute(dat)), side = 3)
        lines(smooth.spline(x, y))
 }

--sundar

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