[R] Creating a .png with just an expression() in it

baptiste auguie baptiste.auguie at googlemail.com
Fri Mar 4 22:15:26 CET 2011


Hi,

I think the easiest way is to use grid graphics,

library(grid)

a = 0.3
b = pi
e = bquote(y[alpha] == .(a) * x[beta]+ .(round(b,2)))

grid.newpage()
grid.text(e)


## if you wanted a snug fit with the device window

e2 = expression(integral(frac(1, alpha + x[beta])*dx, -infinity, +infinity))
g = textGrob(e2)

w = grobWidth(g)
h = grobHeight(g)

dev.new(width=convertUnit(w, "in", valueOnly=TRUE),
        height = convertUnit(h, "in", "y", valueOnly=TRUE))

grid.draw(g)


HTH,

baptiste

On 5 March 2011 02:31, Alexx Hardt <mikrowelle1234 at gmx.de> wrote:
> Hey,
> I'm trying to create an image file with the results of a regression
> analysis. In TeX, the line would be something like:
> $ size = 0.34 + 4.3 var_1 $
>
> Can I create a plot window with just this line in it? I tried playing around
> with plot.new() or dev.new(), but didn't really find something that worked.
>
> Thanks in advance,
>  Alex
>
> --
> alexx at alexx-fett:~$ vi .emacs
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list