Re: [R] expressions and paste
Emily Baldock wrote: I am trying to get a subscript into the title. My expression is quote(bold(apoA[bold(1)])) I have managed to get something near to what I want with sd2 -1.882 measure - g/L direction - increase chem - quote(bold(apoA[bold(1)])) plot(0,0) titletxt - substitute(paste(per , sd2, ,measure, , direction, \n in usual ,chem), list(chem = chem,sd2=sd2,measure=measure,direction=direction)) title(main=titletxt,cex.main=1.4,font.main=2) You don't need paste(), and so we get: sd2 -1.882 measure - g/L direction - increase plot(0,0) titletxt - substitute(bold(per * sd2 * measure * * direction * in usual * apoA[1]), list(sd2 = as.character(sd2), measure = measure, direction = direction)) title(main=titletxt,cex.main=1.4,font.main=2) Uwe Ligges However, I can't get bold text this way. Emily. On 11 Nov 2004 at 12:58, Roger D. Peng wrote: Can you be a bit more specific? Exactly what kind of symbol are you trying to put in the title? -roger Emily Baldock wrote: I have written a function to plot data which will be used for various different chemistries. A simplified version is: plot_data - function(risk,levels,chem,sd2,measure){ plot(risk, levels,main=paste (per, sd2, measure, \n in usual, chem)) } The problem is with the title. This works fine if the variable chem is just text, but if it is an expression then obviously it won't work. I have experimented with various things and I am at a complete loss for how to insert an expression into the middle of a title. If the expression was going in directly I would use main=expression(paste(text , expression, text)) but again this doesn't work. Can anyone help? thanks Emily. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger D. Peng http://www.biostat.jhsph.edu/~rpeng/ __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] expressions and paste
The existence of bold function in base R library is a news for me! I think that you have to read something about plotmath function (with it you can write latex-like expressions). Best. A.S. Alessandro Semeria Models and Simulations Laboratory Montecatini Environmental Research Center (Edison Group), Via Ciro Menotti 48, 48023 Marina di Ravenna (RA), Italy Tel. +39 544 536811 Fax. +39 544 538663 E-mail: [EMAIL PROTECTED] Emily Baldock [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 12/11/2004 12.26 Please respond to emily.baldock To: Roger D. Peng [EMAIL PROTECTED] cc: [EMAIL PROTECTED] Subject:Re: [R] expressions and paste I am trying to get a subscript into the title. My expression is quote(bold(apoA[bold(1)])) I have managed to get something near to what I want with sd2 -1.882 measure - g/L direction - increase chem - quote(bold(apoA[bold(1)])) plot(0,0) titletxt - substitute(paste(per , sd2, ,measure, , direction, \n in usual ,chem), list(chem = chem,sd2=sd2,measure=measure,direction=direction)) title(main=titletxt,cex.main=1.4,font.main=2) However, I can't get bold text this way. Emily. On 11 Nov 2004 at 12:58, Roger D. Peng wrote: Can you be a bit more specific? Exactly what kind of symbol are you trying to put in the title? -roger Emily Baldock wrote: I have written a function to plot data which will be used for various different chemistries. A simplified version is: plot_data - function(risk,levels,chem,sd2,measure){ plot(risk, levels,main=paste (per, sd2, measure, \n in usual, chem)) } The problem is with the title. This works fine if the variable chem is just text, but if it is an expression then obviously it won't work. I have experimented with various things and I am at a complete loss for how to insert an expression into the middle of a title. If the expression was going in directly I would use main=expression(paste(text , expression, text)) but again this doesn't work. Can anyone help? thanks Emily. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger D. Peng http://www.biostat.jhsph.edu/~rpeng/ __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] expressions and paste
Emily, are you right your code work, but this one maybe work better for you : sd2 -1.882 measure - (g/L) direction - increase chem - quote(apoA[bold(1)]) plot(0,0) titletxt - substitute(paste(bold(per) , , bold(sd2), ,bold(measure), , bold(direction), ,,bold(in usual ),bold(chem)),list(chem = chem,sd2=sd2,measure=measure,direction=direction)) title(main=titletxt) Is not elegant but it work! Best regard A.S. Alessandro Semeria Models and Simulations Laboratory Montecatini Environmental Research Center (Edison Group), Via Ciro Menotti 48, 48023 Marina di Ravenna (RA), Italy Tel. +39 544 536811 Fax. +39 544 538663 E-mail: [EMAIL PROTECTED] Emily Baldock [EMAIL PROTECTED] 12/11/2004 13.04 Please respond to emily.baldock To: [EMAIL PROTECTED] cc: Subject:Re: [R] expressions and paste I am using the plotmath function and have read a lot about it! If you run my code, you will find that it works, the problem isn't with creating the expression, but with including it in the title - the chemistry part of the title is bold, it is the rest of the title I want to get bold. Emily. On 12 Nov 2004 at 13:12, [EMAIL PROTECTED] wrote: The existence of bold function in base R library is a news for me! I think that you have to read something about plotmath function (with it you can write latex-like expressions). Best. A.S. Alessandro Semeria Models and Simulations Laboratory Montecatini Environmental Research Center (Edison Group), Via Ciro Menotti 48, 48023 Marina di Ravenna (RA), Italy Tel. +39 544 536811 Fax. +39 544 538663 E-mail: [EMAIL PROTECTED] [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] expressions and paste
I have written a function to plot data which will be used for various different chemistries. A simplified version is: plot_data - function(risk,levels,chem,sd2,measure){ plot(risk, levels,main=paste (per, sd2, measure, \n in usual, chem)) } The problem is with the title. This works fine if the variable chem is just text, but if it is an expression then obviously it won't work. I have experimented with various things and I am at a complete loss for how to insert an expression into the middle of a title. If the expression was going in directly I would use main=expression(paste(text , expression, text)) but again this doesn't work. Can anyone help? thanks Emily. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] expressions and paste
On Thu, 11 Nov 2004, Emily Baldock wrote: I have written a function to plot data which will be used for various different chemistries. A simplified version is: plot_data - function(risk,levels,chem,sd2,measure){ plot(risk, levels,main=paste (per, sd2, measure, \n in usual, chem)) } The problem is with the title. This works fine if the variable chem is just text, but if it is an expression then obviously it won't work. I have experimented with various things and I am at a complete loss for how to insert an expression into the middle of a title. With sd2-10 measure-quote(mu*g*m^{-3}) chem-quote(H[2]*SO[4]) You can use plot(1,1,main=bquote(per *.(sd2)*.(measure)* in usual *.(chem))) or plot(1,1,main=substitute(per *sd2*measure* in usual *chem, list(sd2=sd2,measure=measure,chem=chem)) ) You don't get the newlines, someone else will have to work this out. -thomas __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] expressions and paste
Can you be a bit more specific? Exactly what kind of symbol are you trying to put in the title? -roger Emily Baldock wrote: I have written a function to plot data which will be used for various different chemistries. A simplified version is: plot_data - function(risk,levels,chem,sd2,measure){ plot(risk, levels,main=paste (per, sd2, measure, \n in usual, chem)) } The problem is with the title. This works fine if the variable chem is just text, but if it is an expression then obviously it won't work. I have experimented with various things and I am at a complete loss for how to insert an expression into the middle of a title. If the expression was going in directly I would use main=expression(paste(text , expression, text)) but again this doesn't work. Can anyone help? thanks Emily. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger D. Peng http://www.biostat.jhsph.edu/~rpeng/ __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] expressions and paste
Hi Thomas Lumley wrote: On Thu, 11 Nov 2004, Emily Baldock wrote: I have written a function to plot data which will be used for various different chemistries. A simplified version is: plot_data - function(risk,levels,chem,sd2,measure){ plot(risk, levels,main=paste (per, sd2, measure, \n in usual, chem)) } The problem is with the title. This works fine if the variable chem is just text, but if it is an expression then obviously it won't work. I have experimented with various things and I am at a complete loss for how to insert an expression into the middle of a title. With sd2-10 measure-quote(mu*g*m^{-3}) chem-quote(H[2]*SO[4]) You can use plot(1,1,main=bquote(per *.(sd2)*.(measure)* in usual *.(chem))) or plot(1,1,main=substitute(per *sd2*measure* in usual *chem, list(sd2=sd2,measure=measure,chem=chem)) ) You don't get the newlines, someone else will have to work this out. Expressions (for plotting text) don't handle newlines. A workaround would be to do the title by hand by calling mtext to place two separate expressions on separate lines. Something like ... sd2-10 measure-quote(mu*g*m^{-3}) chem-quote(H[2]*SO[4]) plot_data - function(risk,levels,chem,sd2,measure){ plot(1,1) mtext(substitute(per *sd2*measure, list(sd2=sd2,measure=measure)), side=3, line=2) mtext(substitute(in usual *chem, list(chem=chem)), side=3, line=1) } plot_data(1, 2, chem, sd2, measure) Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html