Rich FitzJohn
2005-Apr-04 11:11 UTC
[R] plotting mathematical notation and values substitution
Gidday, See ?plotmath and demo(plotmath) for lots of information on plotting with mathematical symbols. This produces what you seem to be after (paste() being the missing ingredient): plot(1:10, main=substitute(paste("Monotonic Multigamma run ( *", list(n==len, theta==t1), " * )"), list(len=len, t1=t1))) This does seem to be a lot of work just to get a theta symbol, and this seems just as informative: plot(1:10, main=paste("Monotonic Multigamma run ( * n =", len, "theta =", t1, " * )")) Your second example gives a syntax error for me. Cheers! Rich On Apr 5, 2005 6:50 AM, Luca Scrucca <luca at stat.unipg.it> wrote:> # I add this to let you run the example by copy and paste > > t1 <- 0.5; len <- 1 > # then > > plot(1:10, > main = substitute("Monotonic Multigamma run (" * n == len * ", " * > theta == t1 * ").", list(len = len, t1 = t1))) > > but I got the following: > > Error: syntax error > > I also tried with just one value substitution: > > > plot(1:10, > main = substitute("Monotonic Multigamma run (" theta == t1 * ").", > list(len = len, t1 = t1))) > > which works fine. How can I have more than one value substitution, > together with mathematical notation and text?-- Rich FitzJohn rich.fitzjohn <at> gmail.com | http://homepages.paradise.net.nz/richa183 You are in a maze of twisty little functions, all alike
Peter Dalgaard
2005-Apr-04 11:39 UTC
[R] plotting mathematical notation and values substitution
Luca Scrucca <luca at stat.unipg.it> writes:> Dear R-users, > > I'm trying to add a title on a plot with both mathematical notation and > values substitution. I read the documentation and search the mailing list > but I was not able to solve my problem. Actually, there is a message by > Uwe Ligges on June 2003 which addresses a question very close to mine, but > the code provided doesn't work. The code is the following: > > # I add this to let you run the example by copy and paste > > t1 <- 0.5; len <- 1 > # then > > plot(1:10, > main = substitute("Monotonic Multigamma run (" * n == len * ", " * > theta == t1 * ").", list(len = len, t1 = t1))) > > but I got the following: > > Error: syntax errorThere's a ")" too many, but more importantly, you have the structure A*B==C*D*E==F*G Since * has higher precedence than ==, this involves associative use of relational operators (as in 3 < 2 < 1), which is syntactically forbidden. So you need braces as in A*{B==C}*D*{E==F}*G or, maybe easier to read, use: paste(A, B==C, D, E==F, G} -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Sundar Dorai-Raj
2005-Apr-04 14:57 UTC
[R] plotting mathematical notation and values substitution
Luca Scrucca wrote on 4/4/2005 1:50 PM:> Dear R-users, > > I'm trying to add a title on a plot with both mathematical notation and > values substitution. I read the documentation and search the mailing list > but I was not able to solve my problem. Actually, there is a message by > Uwe Ligges on June 2003 which addresses a question very close to mine, but > the code provided doesn't work. The code is the following: > > # I add this to let you run the example by copy and paste > >>t1 <- 0.5; len <- 1 > > # then > >>plot(1:10, > > main = substitute("Monotonic Multigamma run (" * n == len * ", " * > theta == t1 * ").", list(len = len, t1 = t1))) > > but I got the following: > > Error: syntax error > > I also tried with just one value substitution: > > >>plot(1:10, > > main = substitute("Monotonic Multigamma run (" theta == t1 * ").", > list(len = len, t1 = t1))) > > which works fine. How can I have more than one value substitution, > together with mathematical notation and text? > > Thanks in advance for any reply. > > Luca Scrucca > >Luca, I believe you need paste in this instance: t1 <- 0.5; len <- 1 plot(1:10, main = substitute(paste("Monotonic Multigamma run (", n == len, ", ", theta == t1, ").", sep = ""), list(len = len, t1 = t1))) --sundar
Luca Scrucca
2005-Apr-04 18:50 UTC
[R] plotting mathematical notation and values substitution
Dear R-users, I'm trying to add a title on a plot with both mathematical notation and values substitution. I read the documentation and search the mailing list but I was not able to solve my problem. Actually, there is a message by Uwe Ligges on June 2003 which addresses a question very close to mine, but the code provided doesn't work. The code is the following: # I add this to let you run the example by copy and paste> t1 <- 0.5; len <- 1# then> plot(1:10,main = substitute("Monotonic Multigamma run (" * n == len * ", " * theta == t1 * ").", list(len = len, t1 = t1))) but I got the following: Error: syntax error I also tried with just one value substitution:> plot(1:10,main = substitute("Monotonic Multigamma run (" theta == t1 * ").", list(len = len, t1 = t1))) which works fine. How can I have more than one value substitution, together with mathematical notation and text? Thanks in advance for any reply. Luca Scrucca +-----------------------------------------------------------------------+ | Dr. Luca Scrucca | | Dipartimento di Economia, Finanza e Statistica | | Sezione di Statistica tel. +39-075-5855226 | | Universit? degli Studi di Perugia fax. +39-075-5855950 | | Via Pascoli - C.P. 1315 Succ. 1 | | 06100 PERUGIA (ITALY) | | (o_ (o_ (o_ | | E-mail: luca at stat.unipg.it //\ //\ //\ | | Web page: http://www.stat.unipg.it/luca V_/_ V_/_ V_/_ | +-----------------------------------------------------------------------+