On Aug 28, 2010, at 4:48 PM, Sancar Adali wrote:

My function is like this
sim.res<-gaussian_simulation(p=3, r=4, q=3, c=0.1,d=2,
Wchoice     = "avg",
pre.scaling = TRUE,
oos         = TRUE,
alpha       = NULL,
n = 100, m = 100, nmc = 100)

which is defined as
gaussian_simulation <- function(p, r, q, c,
                                d           = p-1,
                                pprime1     = p+q,   # cca arguments
                                pprime2     = p+q,   # cca arguments
                                Wchoice     = "avg",
                                pre.scaling = TRUE,
                                oos         = TRUE,
                                alpha       = NULL,
                                n = 100, m = 100, nmc = 100)

Not much of a definition...no body???

and I want to title the plot after I invoke the gaussian_simulation function
sim.res<-gaussian_simulation(p=3, r=4, q=3, c=0.1,d=2,
Wchoice     = "avg",
pre.scaling = TRUE,
oos         = TRUE,
alpha       = NULL,
n = 100, m = 100, nmc = 100)
plot(sim.res)
title("p=3, r=4, q=3, c=0.1,d=2")

The following assumes you want the values of those parameters for the title to be picked up from the function's arguments, because the code you offer for the title is syntactically correct. You first need to re- read Bill Venables response regarding bquote which you show no signs of adapting, and then you need to study:

?plotmath

... where you will learn the proper syntax for "=" ("==") and for comma-separated lists. You should not need the quotes inside the bquote call. The "~" (space) and "*" (no space) are syntactic separators inside expressions (in the limited scope of the plotmath perspective). The plotmath interpretation of these is not well described in the documentation (IMO). The help page could easily lead you to think that commas or spaces might be valid separators, or that list() was the same as list() in regular R, and it's only by repeated errors and reading worked examples on r-help that I have learned otherwise.

Consider this and apply lessons learned:

plot(1,1); p=3; r=4; q=3; c=0.1; d=2
title(main= bquote( list(p==.(p), r==.(r), q==.(q), c==.(c), d==. (d)) ) )

# you might get away with not using the "main" argument name, but I think it's bad practice.

--
David.

On Sat, Aug 28, 2010 at 12:53 AM, Sancar Adali <sad...@gmail.com> wrote:

What I want to do is put the arguments I supply to a function into the
title of a plot
Say I'm calling func.1
func.1(a=4,b=4)
plot(....,..., title("a=4, b=4"))
If I'm calling func.1 with different arguments, I want the plot title to
reflect that.
A small detail is that func.1 might have an argument with a default like
c=a+b. I tried using expression but couldn't get it to work.

Is there a way to do this using expression() ?

--
Sancar Adali


David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to