My actual plot call is long and complicated, so I tried to simplify it in
the last message.....here is the actual, using David's proposed solution.
It is not working. What I want to see printed is the following (with
degree symbols after 73 and 296). Since I reuse this string in various
ways, I would like to build a variable to hold it that I can plug into
plots when needed:
*Hours from Reference Time: 201302060000 Model span = 24.00 hrs o ?73
b ?296*
So I set xlab=printXlab value with David's solution, below, in the plot
(this is the actual printXlab value, instead of the simplified one):
* xl = bquote( .(Orthophase[i,j] )*degree )**printXlab<-paste("Hours from
Reference Time:",RefTimeString,"Model span
=",format(magDt,digits=3,nsmall=2),"hrs o",Orthophase[i,j],xl,"
b",Bathyphase[i,j]) *
and here is the result I get (weird duplicates....but most importantly, no
degree symbol:
Hours from Reference Time: 201302060000 Model span = 24.00 hrs o ?73 *
Hours from Reference Time: 201302060000 Model span = 24.00 hrs o ?73 ?73
Hours from Reference Time: 201302060000 Model span = 24.00 hrs o ?73 degree
b ?296 b ?296
b ?296
----------------------
So, I tried to set xlab as Uwe's proposal (without paste, and without
commas):
printXlab<-expression("Hours from Reference Time:" RefTimeString "Model
span =" format(magDt,digits=3,nsmall=2) "hrs o" * Orthophase[i,j] *
degree" b"* Bathyphase[i,j] * degree) # degree~C
I get "unexpected symbol at ^RefTimeStrng" so it doesn't like the missing
commas.
Then I try it with commas, except around the degree parts:
printXlab<-expression("Hours from Reference Time:" RefTimeString "Model
span =" format(magDt,digits=3,nsmall=2) "hrs o" * Orthophase[i,j] *
degree" b"* Bathyphase[i,j] * degree) # degree~C
It runs, but here is what prints:
Hours from Reference Time:
?Then I try with all commas replaced by *:
printXlab<-expression("Hours from Reference Time:"* RefTimeString *"Model
span =" * format(magDt,digits=3,nsmall=2) * "hrs o" * Orthophase[i,j] *
degree * " b"* Bathyphase[i,j] * degree * " ") # degree~C
?And I get degree signs (sort of)!! But the rest is wrong. The variables
are not evaluated:
Hours from Reference Time:RefTimeStringModel span =format(magDt, 3, 2)hrs
oOrthophasei? bBathyphasei?
?I don't really understand what state is required for the degrees to
print....?
Cathy Lee Gierke
*"We are what we repeatedly do. Excellence, then, is not an act, but a
habit." Aristotle*
On Sat, Mar 19, 2016 at 2:04 AM, David Winsemius <dwinsemius at comcast.net>
wrote:
On Mar 18, 2016, at 1:58 PM, Cathy Lee Gierke <leegi001 at umn.edu> wrote: I have searched and tried many things but cannot get anything to work. I just want to print out a degree sign after a the Orthophase number. The following list of "xl" values are all ones I have tried. Granted
they
are not what I want, but I have tried them all, and none of them print
out
a degree symbol...
# xl = expression(paste("Orthophase [", {
# }^o, "]"))
#xl<-~degree~C
#xl<-parse(text = ~degree)
#xl<-parse(text = paste(" ", "~degree", sep = ""))
#xl<-expression(~degree)
xl <- parse(text = paste(Orthophase[i,j], "*degree ~ S",
sep = ""))
printXlab<-paste("Orthophase ",Orthophase[i,j],xl,"
")
plot(MyData$time.hour[plotData],newData[plotData],type="l", xaxt="n",
xlab=printXlab,.....
Ya' know Cathy. It would be nice if you would say what it was that you
actually wanted to do rather than offering multiple failures This does not
throw an error:
xl = expression(paste("Orthophase [", {
}^o, "]"))
plot(1,1,type="l", xaxt="n", xlab=xl)
But perhaps you want to pull in an evaluated result from an object in the
workspace? This should work:
Orthophase <- matrix( 4:1, 2)
i=1;j=1
xl = bquote( .(Orthophase [i,j] )*degree )
plot(1,1,type="l", xaxt="n",
xlab=xl)
Cathy Lee Gierke
*"We are what we repeatedly do. Excellence, then, is not an act, but a
habit." Aristotle*
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 Alameda, CA, USA