I’m trying to add this text to a plot: “Model: y = 1 + 2x – 3x^2 + 4x^3” where actual exponents are rendered as such (no ^ chars). (See screenshot)

Below is repro code. The first text() call works fine (no prepended regular text), but the second does not (with prepended text). (Execute soTest() to repro.)

Any suggestions? I guess I don’t know which R keywords to search for to find a solution. Any help would be appreciated! (Please pardon the camel-casing, I’m writing a slide deck for an audience with at least a few non-R coders.)

`evalPoly = function( x, coeff ) { if ( length( coeff ) < 1 ) return( c(0) ) termSum <- 0 for ( i in 1:length(coeff) ) { termSum <- termSum + coeff[i] * x^(i-1) } return( termSum ) } soTest <- function() { coeff <- c( 1, 2, -3, 4 ) x <- 1:8 y <- evalPoly( x, coeff ) plot( x, y ) text( 2, 1600, parse( text="1+2*x-3*x^2+4*x^3" ), adj=0 ) text( 2, 1400, parse( text="Model: y = 1+2*x-3*x^2+4*x^3" ), adj=0 ) } `