Re: [R] superscript characters in title with '+'
On Oct 26, 2010, at 11:15 AM, Gavin Simpson wrote: On Fri, 2010-10-22 at 15:39 +0200, Claudia Beleites wrote: On 10/22/2010 03:15 PM, DrCJones wrote: Being a chemist, it seemed natural to me to put the i after the concentration brackets into a subscript - though you didn't say you want that. A more "correct" expression would be: group ("[", Ca^'2+', "]") [i]~onsets You don't need to quote the 2+, but if you don't quote it you have to give R's parser something to work with on the RHS of "+". phantom() is useful in such cases: plot(1:10, ylab = expression(group("[", Ca^{2+phantom()}, "]") [i]~onsets)) for example, produces similar output to your version. My preference is to use fewer strings in these expressions, but then again my version involves more typing. You pays your money... as they say. You could use doubled single quotes '' in the same position as that phantom(). Of course that mean means the net effect is just moving quotes around and probably not in the most intuitive manner. -- David. G where you can easier see that the "[" and "]" are special left and right delimiters. Note that the only term that needs to be "hidden" as character is the charge, as R doesn't know this way of writing ion charges and supposes + to be an infix operator. Cheers, Claudia -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ 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. __ 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.
Re: [R] superscript characters in title with '+'
On Fri, 2010-10-22 at 15:39 +0200, Claudia Beleites wrote: > On 10/22/2010 03:15 PM, DrCJones wrote: > > Being a chemist, it seemed natural to me to put the i after the concentration > brackets into a subscript - though you didn't say you want that. > > A more "correct" expression would be: > > group ("[", Ca^'2+', "]") [i]~onsets You don't need to quote the 2+, but if you don't quote it you have to give R's parser something to work with on the RHS of "+". phantom() is useful in such cases: plot(1:10, ylab = expression(group("[", Ca^{2+phantom()}, "]")[i]~onsets)) for example, produces similar output to your version. My preference is to use fewer strings in these expressions, but then again my version involves more typing. You pays your money... as they say. G > where you can easier see that the "[" and "]" are special left and right > delimiters. Note that the only term that needs to be "hidden" as character is > the charge, as R doesn't know this way of writing ion charges and supposes + > to > be an infix operator. > > > Cheers, > > Claudia -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ 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.
Re: [R] superscript characters in title with '+'
"Er, I don't see any italics in the output or implied by the expression. " Freudian slip... ...font superscripting is what I meant All is perfectly clear now. Thanks again! -- View this message in context: http://r.789695.n4.nabble.com/superscript-characters-in-title-with-tp3006981p3007239.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] superscript characters in title with '+'
On 10/22/2010 03:15 PM, DrCJones wrote: Hi, Thanks for all of your replies! David, a slightly modified version of what you gave did the trick: hist(X,main = expression("["*Ca**""^paste(2,"+")*"]i"~'onsets')) here you put the 2+ into the superscript of a superscript. compare these four: hist(X,main = expression(Ca**2~Ca^2~Ca**""^2~Ca^""^2)) ** and ^ both mean power But I prefer the way '2+' is italicized in the solution Dennis gave: hist(X, main = bquote('[Ca'^'2+'*']i'~'onsets'), xlab = 'sec') I think I understand it now - the '^' symbol must be followed by the '*' symbol to signify the end of font italicization; no, the ^ is the power function infix operator, as in x^2 = x². * is multiplication, but the multiplication is written without dot: x * y = x ⋅ y = xy It is abused here to connect terms into one expression. and '~' must be used to signify spaces. yes The only thing I still don't get is why square brackets rather than quotation marks surround the 'i' in the solution Claudia gave: hist(X, main=expression("[" * Ca^"2+" * "]" [i]~'onsets'), xlab = 'sec') the square bracket operator marks indices, which are written as subscript. So x[i] produces what in LaTeX would be x_i Being a chemist, it seemed natural to me to put the i after the concentration brackets into a subscript - though you didn't say you want that. A more "correct" expression would be: group ("[", Ca^'2+', "]") [i]~onsets where you can easier see that the "[" and "]" are special left and right delimiters. Note that the only term that needs to be "hidden" as character is the charge, as R doesn't know this way of writing ion charges and supposes + to be an infix operator. Cheers, Claudia -- Claudia Beleites Dipartimento dei Materiali e delle Risorse Naturali Università degli Studi di Trieste Via Alfonso Valerio 6/a I-34127 Trieste phone: +39 0 40 5 58-37 68 email: cbelei...@units.it __ 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.
Re: [R] superscript characters in title with '+'
On Oct 22, 2010, at 9:15 AM, DrCJones wrote: Hi, Thanks for all of your replies! David, a slightly modified version of what you gave did the trick: hist(X,main = expression("["*Ca**""^paste(2,"+")*"]i"~'onsets')) But I prefer the way '2+' is italicized in the solution Dennis gave: I agree. Dennis' version was more compact. And it worked if simply used as an argument to expression(), and it generalizes to substitution. Superior in every way. hist(X, main = bquote('[Ca'^'2+'*']i'~'onsets'), xlab = 'sec') I think I understand it now - the '^' symbol must be followed by the '*' symbol to signify the end of font italicization; Er, I don't see any italics in the output or implied by the expression. and '~' must be used to signify spaces. The only thing I still don't get is why square brackets rather than quotation marks surround the 'i' in the solution Claudia gave: hist(X, main=expression("[" * Ca^"2+" * "]" [i]~'onsets'), xlab = 'sec') Because the "[]" function in plotmath does subscripting. I guess she figured that was what you wanted. You really need to study ?plotmath some more. -- View this message in context: http://r.789695.n4.nabble.com/superscript-characters-in-title-with-tp3006981p3007188.html Sent from the R help mailing list archive at Nabble.com. __ 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. 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.
Re: [R] superscript characters in title with '+'
Hi, Thanks for all of your replies! David, a slightly modified version of what you gave did the trick: hist(X,main = expression("["*Ca**""^paste(2,"+")*"]i"~'onsets')) But I prefer the way '2+' is italicized in the solution Dennis gave: hist(X, main = bquote('[Ca'^'2+'*']i'~'onsets'), xlab = 'sec') I think I understand it now - the '^' symbol must be followed by the '*' symbol to signify the end of font italicization; and '~' must be used to signify spaces. The only thing I still don't get is why square brackets rather than quotation marks surround the 'i' in the solution Claudia gave: hist(X, main=expression("[" * Ca^"2+" * "]" [i]~'onsets'), xlab = 'sec') -- View this message in context: http://r.789695.n4.nabble.com/superscript-characters-in-title-with-tp3006981p3007188.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] superscript characters in title with '+'
Hi: Try X <- rnorm(100) hist(X, main = bquote('[Ca'^'2+'*']i'~'onsets'), xlab = 'sec') or hist(X, main = bquote('[Ca*]'*i^'2+' ~'onsets'), xlab = 'sec') I'm not sure which one you want, though. HTH, Dennis On Fri, Oct 22, 2010 at 4:01 AM, DrCJones wrote: > > Hi, > > How can I get the '2+' into superscript in the following title: > > '[Ca2+]i onsets' > > I tried the command below, but it doesn't work. What am I missing? > > hist(X, main=expression(([Ca*]i^2+) 'onsets'), xlab = 'sec') > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/superscript-characters-in-title-with-tp3006981p3006981.html > Sent from the R help mailing list archive at Nabble.com. > > __ > 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. > [[alternative HTML version deleted]] __ 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.
Re: [R] superscript characters in title with '+'
On Oct 22, 2010, at 7:01 AM, DrCJones wrote: Hi, How can I get the '2+' into superscript in the following title: '[Ca2+]i onsets' I tried the command below, but it doesn't work. What am I missing? The first is an unambiguous description of what you want, but here are some guesses (since it was entirely confusing when above you put the "i" after the rt-square-bracket, and below put it before the "2+"): expression("["*Ca*"]"*i^paste(2,"+")~'onsets') expression("["*Ca*"]"^paste(2,"+")*i~'onsets') If one of those guesses is correct then what you were missing was an understanding of the differences between the plotmath syntax and regular printing. The characters"[", "]", and "+" are special so if you just want them treated as ordinarily characters, you need to surround them in quotes. If you want to put "2+" as superscript, the plotmath paste function (not to be confused with the ordinary R paste() ) will let you group sub-expressions. It would also be possible to use the group() expression-function. And the final missing piece is the knowledge that itmes in an expression are separated by "*"'s and "~"'s rather than commas or spaces. ?plotmath # which I think does an inadequate job of describing the features mentioned above. If you need to insert values in expressions then: ?bquote or ? substitute Took me a couple of years to feel that I had a decent chance of getting an expression correct on even the second or third try. hist(X, main=expression(([Ca*]i^2+) 'onsets'), xlab = 'sec') 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.
[R] superscript characters in title with '+'
Hi, How can I get the '2+' into superscript in the following title: '[Ca2+]i onsets' I tried the command below, but it doesn't work. What am I missing? hist(X, main=expression(([Ca*]i^2+) 'onsets'), xlab = 'sec') -- View this message in context: http://r.789695.n4.nabble.com/superscript-characters-in-title-with-tp3006981p3006981.html Sent from the R help mailing list archive at Nabble.com. __ 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.