科学网

 找回密码
  注册

tag 标签: Sweave

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

nine "mark-up" languages that can be used to "Sweave" together data, code, and r
jianfengmao 2010-7-21 19:28
九种mark-up languages that can be used to Sweave together data, code, and results: * LaTeX: The Sweave utility in base R provides a method for creating LaTeX files wich can then be converted to PDF files. * HTML: The R2HTML, HTMLutils, hwriter, prettyR, and Hmisc packages provide methods for outputting R code and output to HTML pages. * asciiDoc: The ascii package provides methods for creating asciiDoc files which can then be converted to HTML, XML, or LaTeX files. See examples here. * t2tags: The ascii package provides methods for creating t2tags files which can then be converted to HTML, XML, or LaTeX files. See examples here. * reStructuredText: The ascii package provides methods for creating reStructuredText files which can then be converted to HTML, XML, or LaTeX files. See examples here. * org: The ascii package provides methods for creating org files which can then be converted to HTML, XML, or LaTeX files. See examples here. * textile: The ascii package provides methods for creating textile files which can then be converted to HTML, XML, or LaTeX files. See examples here. * OpenOffice: The odfWeave package provides methods for creating files in the open document format (odf) which can then be opened in OpenOffice. These files can then be output to a vareity of formats. * MSWord: The R2WD package provides a markup language for creating MSWord documents from within R. The SWord software provides the ability to use Sweave-like markup to create MSWord documents. Inference for R is proprietary software that allows the user to embed R code and output into a Microsoft Word document. 这里的部分内容转自网络
个人分类: R and Statistics|2729 次阅读|0 个评论
统计结果的保存:Sweave in R
zjlcas 2009-8-6 22:50
Sweave in R? Sweave是R中的一个函数,用来生成统计报告的。如果你希望将R的代码和LaTeX的代码整合到一个文件中,可以用Sweave函数生成.tex文件,利用安装好的LaTeX编译TeX文件就能生成包含相应计算结果的pdf文件。 Sweave处理的是.Snw文件,其格式几乎与.TeX文 件相同,不同的是,其中的R代码包含在= 和 @ 之间,其中内部可以放置Sweave处理时的参数。 下面是一个简单的.Rnw文件的内容: \documentclass {article} \title{ How to use Sweave? } \author{ Jinlong Zhang } \begin{document} \maketitle In this example we use hclust() in R to perform a cluster analysis into a \LaTeX{} document: = x-c(1,2,6,8,11) dim(x)-c(5,1) d-dist(x) d hc-hclust(d, single) dend-as.dendrogram(hc) @ the dendrograms are also included: \begin{center} fig=TRUE,echo=FALSE= par(mfrow = c(2, 2),mar = c(4,3,1,2)) plot(dend) plot(dend, nodePar=list(pch = c(1,NA), cex=0.8, lab.cex=0.8), type = t, center=TRUE) plot(dend, edgePar=list(col = 1:2, lty = 2:3), dLeaf=1, edge.root = TRUE) plot(dend, nodePar=list(pch = 2:1, cex=.4*2:1, col=2:3), horiz=TRUE) @ \end{center} \end{document} 将以上代码粘贴到记事本中,另存为test.Rnw文件,放置到R的工作目录,运行Sweave(test.Rnw)即可生成.TeX文件和相应的图形文件。eps图形文件等将在变异TeX文档时引用图形时用到。 可以看到,其中包含了两块R代码: 第一部分为 = x-c(1,2,6,8,11) dim(x)-c(5,1) d-dist(x) hc-hclust(d, single) dend-as.dendrogram(hc) @ 第二部分为 fig=TRUE,echo=FALSE= par(mfrow = c(2, 2),mar = c(4,3,1,2)) plot(dend) plot(dend, nodePar=list(pch = c(1,NA), cex=0.8, lab.cex=0.8), type = t, center=TRUE) plot(dend, edgePar=list(col = 1:2, lty = 2:3), dLeaf=1, edge.root = TRUE) plot(dend, nodePar=list(pch = 2:1, cex=.4*2:1, col=2:3), horiz=TRUE) @ 如果想要生成相应的pdf,只需用LaTeX变异相应的TeX文件即可。 注意:编译的时候,LaTeX会可能会提示找不到Sweave.sty文件,该文件可在C:\Program Files\R\R-2.9.0\share\texmf目录下找到,拷贝到TeX文件所在的目录下即可。 提供几个进一步学习的链接: Sweave函数的作者Friedrich Leisch的主页: http://www.stat.uni-muenchen.de/~leisch/Sweave/ www.stat.umn.edu/~charlie/Sweave http://stat.epfl.ch/webdav/site/stat/shared/Regression/EPFL-Sweave-powerdot.pdf http://biosun1.harvard.edu/courses/individual/bio271/lectures/L7/Sweave-manual-20021007.pdf
个人分类: 统计分析|12578 次阅读|0 个评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-27 19:43

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部