# Sweave Example 2 using a HTML file

Eric Lecoute

HTML Sweaving relies on R2HTML package, which uses CSS styles. Thus, you can change the whole aspect of your output, simply by changing the CSS file. Simply call:

<>= Sweave("example2.snw", driver=RweaveHTML(), cssfile="pastel.css") @

You can insert scalars in text by using expressions <Sexpr expr>. If the result is a vector, only the first element is returned: see the call <Sexpr round(rnorm(10),2)> transformed to: . Also any HTML tag can be used to format this output: see this colored actual year computed by date(): .

As we use HTML() functions, some formatting is already applied on most R objects. This this regression result:

<>= x=1:10 y=3*x+2+3*rnorm(10) reg1=lm(y~x) summary(reg1) @

By default, the last manipulated object in a code chunk is evaluated and a call to HTML is done to catch it's HTML representation, which is inserted in the output file. You can override this behaviour by explicitely return a string containing HTML codes as output. This allows to have more controls on output, as you can do exactly what you want from R. To specify that output are already HTML, add the option `results=html` to your code chunk.

<>= HTML(data.frame(x,y),digits=2,Border=2) @

Finally, some more options are added to handle graphs, such as `width`, `height`, `border`, `align` and `caption`

<>= boxplot(x,main="") @