[R] degree sign

Cathy Lee Gierke leegi001 at umn.edu
Mon Mar 21 03:04:46 CET 2016


Would it make any difference that I am not a member of the list?  Did you
see Uwe's response?

Cathy Lee Gierke

*"We are what we repeatedly do.  Excellence, then, is not an act, but a
habit." Aristotle*

On Sun, Mar 20, 2016 at 9:02 PM, David Winsemius <dwinsemius at comcast.net>
wrote:

>
> It's a bit puzzling that neither of my replies to your postings have
> appeared on the R help list Archive. I normally reply-all to questions and
> despite the fact that you are sending in a formatted style, I have my
> client configured to reply in plain text. My client "Sent folder" has
> copies and the email addressees include r-help at r-project.org. I suppose
> this is a further "test" posting sent as reply-to-all. If it does not
> appear, then perhaps I can track down the problem by examining headers.
>
>
> --
> David.
>
>
> > On Mar 19, 2016, at 9:44 PM, Cathy Lee Gierke <leegi001 at umn.edu> wrote:
> >
> > Wonderful!  That works.
> >
> > 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 6:44 PM, David Winsemius <dwinsemius at comcast.net>
> wrote:
> >
> > > On Mar 19, 2016, at 1:58 PM, Cathy Lee Gierke <leegi001 at umn.edu>
> wrote:
> > >
> > > 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
> >
> > The degree-object in plotmath needs to be placed within an R object of
> class expression.
> >
> > For multi-line expression delivery in the outer portions of a graphic, I
> would recommend using mtext:
> >
> > -------------
> >
> > myexpr <- expression("Hours from Reference Time: 201302060000",
> >                       "Model span = 24.00 hrs     o
> −73"*degree*phantom("      ")*"b −296"*degree)
> >
> > plot(1,1)
> >  mtext(myexpr[[1]] , side=1,line=2)
> >  mtext(myexpr[[2]] , side=1,line=3)
> >
> > >
> > > 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])
> >
> > If you are tryng to substitute
> > >
> > > 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
> >
> > You may want to use substitute or bquote to create an expression that
> has evaluated values (if you will) for:
> >
> > Orthophase[i,j]
> > Bathyphase[i,j]
> >
> > Something like this
> >
> >  orth=3.56
> >  bathy=5.87
> >  RefTimeStr <- "test"
> >  magDT <- "1999-01-01";
> >  printXlab  <-  list( bquote("Hours from Reference Time:"~
> .(RefTimeStr)),
> >          bquote("Model span ="*.(format(magDt,digits=3,nsmall=2))* "
> hrs    o" * .(orth) * degree*"C     b"* .(bathy) * degree*C))
> >  plot(1,1, xlab="")
> >  mtext(sapply( printXlab, as.expression) , side=1,
> >            line=2:3)
> >
> >
> > --
> > David.
> >
> > >
> > > 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
> > >
> > >
> >
> > David Winsemius
> > Alameda, CA, USA
> >
> >
>
> David Winsemius
> Alameda, CA, USA
>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list