Hello R Masters and the Rest of Us: The first of these works fine, the 2nd is accepted but too literal (the "%->%" is shown in the plot label and in the wrong position). The 3rd throws and error due to "unexpected SPECIAL". Would someone recommend a way to format this? I want the two phrases connected by a right arrow. TIA, these things always elude me. Bryan *********** Bryan Hanson Professor of Chemistry & Biochemistry DePauw University xlab1 <-expression(paste("Phase Angle ", phi, " Neat-O")) xlab2 <- expression(paste("treatment: low stress", "high stress", sep = "%->%")) xlab3 <- expression(paste("treatment: low stress", %->%, "high stress")) plot(1:10, main = xlab1) plot(1:10, main = xlab2)
Interesting. I don't know the explanation, but look at this: # works plot(1:10, 1:10, xlab=expression(a %->% b)) # doesn't work plot(1:10, 1:10, xlab=expression(%->%)) # works plot(1:10, 1:10, xlab=expression(paste("something" %->% "else"))) # doesn't work plot(1:10, 1:10, xlab=expression(paste("something", %->%, "else"))) The "doesn't work" examples give the same error you report: Error: unexpected SPECIAL in "plot(1:10, 1:10, xlab=expression(%->%" And then there's: # doesn't work, as expected plot(1:10, 1:10, xlab=expression(paste("something" phi "else"))) # works plot(1:10, 1:10, xlab=expression(paste("something", phi, "else"))) # works plot(1:10, 1:10, xlab=expression(paste("something" %==% "else"))) # doesn't work plot(1:10, 1:10, xlab=expression(paste("something", %==%, "else"))) So it seems that when using an expression element bracketed by percent signs, the commas in paste cause an error, even though they are otherwise necessary. Hm. This is on a clean R 2.11 session on linux (I know, but that's the latest version in the UNR repository, and I don't use R enough on this netbook to install a non-repo version). I can try again tomorrow on an up-to-date system. Sarah - Hide quoted text - On Wed, Jun 22, 2011 at 8:10 PM, Bryan Hanson <hanson at depauw.edu> wrote:> Hello R Masters and the Rest of Us: > > The first of these works fine, the 2nd is accepted but too literal (the > "%->%" is shown in the plot label and in the wrong position). The 3rd > throws and error due to "unexpected SPECIAL". Would someone recommend a way > to format this? I want the two phrases connected by a right arrow. > > TIA, these things always elude me. Bryan-- Sarah Goslee http://www.functionaldiversity.org
On Jun 22, 2011, at 8:10 PM, Bryan Hanson wrote:> Hello R Masters and the Rest of Us: > > The first of these works fine, the 2nd is accepted but too literal > (the "%->%" is shown in the plot label and in the wrong position). > The 3rd throws and error due to "unexpected SPECIAL". Would someone > recommend a way to format this? I want the two phrases connected by > a right arrow. > > TIA, these things always elude me. Bryan > *********** > Bryan Hanson > Professor of Chemistry & Biochemistry > DePauw University > > xlab1 <-expression(paste("Phase Angle ", phi, " Neat-O")) > xlab2 <- expression(paste("treatment: low stress", "high stress", > sep = "%->%")) > xlab3 <- expression(paste("treatment: low stress", %->%, "high > stress")) > > plot(1:10, main = xlab1) > plot(1:10, main = xlab2)Doesn't seem that %->% "works" without flanking terms xlab3 <- expression(treatment*":"~low~stress %->% high~stress) plot(1, main=xlab3) Or: xlab3 <- expression("treatment: low stress" %->% high~stress) plot(1, main=xlab3) -- David Winsemius, MD West Hartford, CT