Hi Kyle,
First off, my deepest gratitude to the Sweave developers: this tool has
improved my quality greatly.
A question in my work I use \Sexpr{} statements scalar values and the xtable
package for all manner of tables. What I'd like to do is to use a vector
inline, rather than a whole separate table. Something like:
%%%%%%%%%%%%%%%% begin code
% Latex junk
% Sweave block:
<<>>=
covmat <- cov(matrix(runif(100),ncol=3))
@
% back to Latex, typing up a report, my homework, etc.
The first column of the covariance matrix is $(\Sexpr{covmat[1,1]},
\Sexpr{covmat[2,1]}, \Sexpr{covmat[3,1]})^T$
%%%%%%%%%%%%%%%%% end code
but, of course, this is poor way of going about it. Any suggestions?
<<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
______________________________________________
R-help@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.