Resize Arrays and Figures in a Sweave document.

How is it possible to resize figures produced via a Sweave script?

I tried `scalebox` and others, but I can't succeed to obtain a figure with an acceptable size in my beamer with direct Sweave output like:

``````<<MyGraph,fig=T>>
x <- rnorm(1000)
y <- rnorm(1000)
plot(x,y)
@
``````

Good answers for figures but for text output ? (see below)

I would also like indications to resize for example an output which is too large for the screen.

For example:

``````<<MyBigData.Frame,echo=off>>
summary(mybigdata.frame)
@
``````
-
Please don't tag it with `beamer` as long it isn't `beamer` related, i.e. it works with other classes but not with `beamer`. If this is the case please state that more clearly in the question. Thanks! –  Martin Scharrer Feb 21 '11 at 11:13

For the figures something like,

``````«MyGraph,fig=TRUE,height=4,width=8»=
…
@
``````

should work. (It defaults to inches.)

To set the default size of all figures in the document with respect to the text block, try, e.g.,

``````\setkeys{Gin}{width=0.9\textwidth}
``````

You can set absolute widths (in inches or cm) that way, too.

-

I usually put

``````\usepackege[nogin]{sweave}
``````

to the preamble to override default Sweave scaling. That way the width and height of the figure could be controlled by the arguments to the code chunk

``````<<label=test, fig=TRUE, width=5, height=5>>=
x <- rnorm(1000)
y <- rnorm(1000)
plot(x,y)
@
``````

Depends on your settings you maybe need to copy `Sweave.sty` to your local directory for this to work.

-