Skip to content

Sweave \Sexpr{} advice please

3 messages · Kyle Matoba, Dieter Menne, Tobias Verbeke

#
Kyle Matoba <kmmatoba <at> ucdavis.edu> writes:
To unclutter the text in Sexpr, I normally prepare the results in the 
Sweave block in advance

Dieter

covmat <- cov(matrix(runif(30),ncol=3))
ft = paste(round(covmat[,3]),collapse=", ")
ft
named = c(Val=3,StdDev=4,p=0.4)
ft = paste(names(named),named,sep="= ",collapse=", ")
ft
#
Hi Kyle,
<<loadPkg, echo=FALSE>>=
   require(xtable)
@

<<>>=
covmat <- cov(matrix(runif(99), ncol=3)) # 99 not 100
@

The first row of the\dots is
<<firstRow, echo = FALSE, results=tex>>=
	xtable(covmat[1,,drop=FALSE])
@

This should get you started. Be sure to
explore the facilities of the xtable package
(you can use captions, labels etc.):

?xtable
?print.xtable

The results=tex option to the chunk is
important as well, of course.

HTH,
Tobias