Skip to content
Prev 175600 / 398506 Next

Problem with mathematical expression and loop

On 3/31/2009 9:15 AM, Denis Aydin wrote:
Don't use a character vector, use expressions from the beginning:

trans.expr <- expression(x^3, x^2, x, frac(1,x), frac(1,x^2),
                         frac(1,x^3), sqrt(x), log(x), frac(1,sqrt(x)))
for (i in 1:9) hist(x[i], main=trans.expr[i])

If you really need to use strings, then you need parse() to convert them 
to expressions.

Duncan Murdoch