[R] Some problems with Sweave

martin.gaston at unavarra.es martin.gaston at unavarra.es
Fri May 23 10:16:33 CEST 2008


Dear R users,
I'm working in a brief R-tutorial to a group of students. To make that I'm
using Sweave but I've got two problems:

First, I want show how R operates with the matrix type but, I write in the
.rnw document the code

<<echo=T,results=tex>>=
 matriz <- matrix(vector,nrow=3,ncol=6)
 matriz
@

and after compilating the LaTex document I obtain in the pdf the next text

> matriz <- matrix(vector, nrow = 3, ncol = 6)
> matriz
[,1] [,2] [,3] [,4] [,5] [,6] [1,] 1 4 1 4 1 4 [2,] 2 5 2 5 2 5 [3,] 3 6 3
6 3 6

My question is, How must I do To obtain in the pdf somethin near to

> matriz <- matrix(vector, nrow = 3, ncol = 6)
> matriz
     [,1] [,2] [,3] [,4] [,5] [,6]
[1,]    1    4    1    4    1    4
[2,]    2    5    2    5    2    5
[3,]    3    6    3    6    3    6

I`ve tought in xtable but the aspect is not as the R console.

On the other hand I want show the list type R-treatment, the problem here
is in the LaTex compilation
I write in the .rnwd document

<<echo=T,results=tex>>=
 lista <- list(cadena='String',vector=c(1,1,1),logica=TRUE)
 lista$cadena
@

the Sweave call is ok, but when I compile the .tex document, It produces
errors caused by the $ simbols. Anybody knows how save this problem?

Thanks in advance,
Martín Gastón



More information about the R-help mailing list