plot - Variable part in an expression( ... ) with R -


this question has answer here:

i display physical units in r plot. in order have better typography, use expression function way:

plot(rnorm(10),rnorm(10),main=expression(µg.l^-1)) 

suppose unit not statically known, , given variable [unit]:

unit = 'µg.l^-1' plot(rnorm(10),rnorm(10),main=expression(unit)) 

this of course not work because [unit] not substituted value. there means achieve anyway?

edit: should stress main difficulty here unit displayed sent string plot function. contents of unit should interpreted expression @ point (that transformed string expression object), , answer texb comes handy. please unmark question duplicate, since use of parse fundamental here , not mentionned in post suggest.

how about:

unit = 'µg.l^-1' plot(rnorm(10),rnorm(10),main=parse(text=unit)) 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -