[R] text processing for plots

David Carslaw d.c.carslaw at its.leeds.ac.uk
Fri Sep 5 15:26:12 CEST 2008


Hi R people,

I want to write some functions to automate the plotting of some expressions
that use some of the plotmath capabilities.

An example is a string supplied to a plot call such as:

plot(1, 1, ylab = "pm10 (ug/m3)")

This should actually appear like:

plot(1, 1, ylab = expression("PM"[10] * " (" * mu * "g m" ^-3 * ")"))

 i.e. pollutant name, units

What I would like to do is write a function that will automatically detect
certain strings, reformat them, and supply it as an argument to plot.  I
could just search for the whole string, but I would like something more
flexible because there will be many combinations of pollutant (pm10, nox,
no2...) and units (ug/m3, mg/m3, ng/m3...).

My question is this - is there a way to separately process the pollutant and
units and supply the correct overall expression to plot?

I'm not sure of the best strategy for this having read through previous
posts etc., and would appreciate your help!

Many thanks.

David Carslaw

-----
Institute for Transport Studies
University of Leeds
-- 
View this message in context: http://www.nabble.com/text-processing-for-plots-tp19331219p19331219.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list