Dear List, 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? Thanks in advance. Regards, Kyle [[alternative HTML version deleted]]
Kyle Matoba <kmmatoba <at> ucdavis.edu> writes:> 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: > > % 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$ >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,> 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
Possibly Parallel Threads
- Sweave and \Sexpr{}
- R2HTML doesn't split paragraphs originating from \Sexpr[results=rd]
- [PATCH] tools/xend: Only add cpuid and cpuid_check to sexpr once
- Top level \Sexpr and R CMD check
- Sweave processes \Sexpr in commented LaTeX source (2.3.1patched and 2.4.0)