hello, i need to annotate a plot with an expression and a variable value - like: plot(1:4) dat<-1:2 text(2:3,2:3,expression(paste(bar(x)==dat))) ... but with the dat values plotted, 1 at x=2,y=2, and 2 at x=3,y=3. maybe someone can help? yours, kay ----- ------------------------ Kay Cichini Postgraduate student Institute of Botany Univ. of Innsbruck ------------------------ -- View this message in context: http://r.789695.n4.nabble.com/how-to-paste-a-vector-to-expression-tp2328564p2328564.html Sent from the R help mailing list archive at Nabble.com.
On Aug 17, 2010, at 11:51 AM, Kay Cichini wrote:> > hello, > > i need to annotate a plot with an expression and a variable value - > like: > > plot(1:4) > dat<-1:2 > text(2:3,2:3,expression(paste(bar(x)==dat))) > > > ... but with the dat values plotted, 1 at x=2,y=2, and 2 at x=3,y=3.One way ... actually the first success after several earlier failed efforts that I thought should have worked : plot(1:4) dat<-1:2 text(2:3,2:3,labels=sapply(dat, function(x) as.expression(substitute(list(bar("x") == x), list(x=x) )) )) -- David Winsemius, MD West Hartford, CT
..thank you! this generally works well - but after saving the result as jpeg i noticed that the printed "=" used with the expression looks different from the "=" signs used for the same graph for another simple text annotation (i.e. the linewidths used with the expression are much smaller). maybe there is still another solution? - really no way using the paste command? curiously paste(expression(bar(x)),"=",dat) does not work.. thanks, kay ----- ------------------------ Kay Cichini Postgraduate student Institute of Botany Univ. of Innsbruck ------------------------ -- View this message in context: http://r.789695.n4.nabble.com/how-to-paste-a-vector-to-expression-tp2328564p2329011.html Sent from the R help mailing list archive at Nabble.com.