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
|