有没有办法使用StatET Eclipse插件的外部工具函数编织和生成.rmd文件?

[英]Is there a way to knitr and produce .rmd files using the external tools function of the StatET Eclipse plugin?


I'm becoming a fan of reproducible analyses and of Sweave, Beamer and specially of the knitr package.

我正在成为可重复分析和Sweave,Beamer以及特别针织包装的粉丝。

RStudio allows to Sweave and knit documents with just one click, but although RStudio is easy to install, it is quite unstable and does not have the maturity and flexibility of the StatET plugin from Eclipse. Most tutorials or listservs tend to refer back to the RStudio IDE when asking questions about knitr and RMarkdown, but there's little out there about how to install and turn Markdown files into .Rmd using the knitr package. Jeffrey Horner said when he announced the R markdown package that:

RStudio允许只需单击一下即可扫描和编织文档,但是虽然RStudio易于安装,但它非常不稳定,并且没有Eclipse的StatET插件的成熟度和灵活性。在询问有关knitr和RMarkdown的问题时,大多数教程或列表服务器都倾向于返回RStudio IDE,但是关于如何使用knitr包安装Markdown文件并将其转换为.Rmd几乎没有。 Jeffrey Horner在宣布R降价套餐时表示:

"Markdown documents to HTML, created in collaboration with RStudio. It offers the complete R Markdown feature set available in their best-of-breed IDE, however useRs can integrate markdown into their own toolchain of choice."

“将Markdown文档转换为HTML,与RStudio合作创建。它提供完整的R Markdown功能集,可在其最佳IDE中使用,但useRs可将markdown集成到他们自己选择的工具链中。”

The last sentence is what I have not been able to figure out. Elsewhere, I've seen suggested to manually knitr by using library(knitr); knit('myfile.Rmd'), however, when attempting to do this, I receive an error:

最后一句是我无法弄清楚的。在其他地方,我见过建议使用库(knitr)手动编织;编织('myfile.Rmd')但是,在尝试这样做时,我收到一个错误:

Warning in file(con, "r") :
  cannot open file 'My file.Rmd': No such file or directory
Error in file(con, "r") : cannot open the connection

I was able to turn the My file.md file into html using:

我能够使用以下命令将My file.md文件转换为html:

library(markdown)
markdownToHTML(file = "C:/Dropbox/eclipse/8. CM/Myfile", output="C:/Dropbox/eclipse/8. CM/Myfile.html")

However, the R code is not run, and I suspect that I need to knit the .Rmd file first. Any help or directions about how to be able to knitr markdown files in StatET or somewhere else than Rstudio would be much appreciated.

但是,R代码没有运行,我怀疑我需要先编织.Rmd文件。任何有关如何能够在StatET或Rstudio以外的地方编织markdown文件的帮助或指示都将非常感激。

I'm using R version 2.15.1 (2012-06-22) on a Windows 7 Professional OS. Eclipse Version: 3.8.0 and StatET 3.0.

我在Windows 7专业版操作系统上使用R版本2.15.1(2012-06-22)。 Eclipse版本:3.8.0和StatET 3.0。

1 个解决方案

#1


1  

One way to do it is to use an R snippet:

一种方法是使用R片段:

1) create a stateET R project, with this file https://raw.github.com/yihui/knitr-examples/master/001-minimal.Rmd in it.

1)创建一个stateET R项目,其中包含此文件https://raw.github.com/yihui/knitr-examples/master/001-minimal.Rmd。

2) in Windows-> Preferences -> StatET -> Run/Debug -> R Code Snippets

2)在Windows-> Preferences - > StatET - > Run / Debug - > R Code Snippets中

click "Add...". to create a new snipped called Rmd2html. content of the snippet:

单击“添加...”。创建一个名为Rmd2html的新剪辑。代码段的内容:

file <- "${selected_resource_loc}"
if (!nzchar) stop('Select a file first')
library(knitr)
library(markdown)
library(tools)
md_file <- knit(file)
html_file <- paste(file_path_sans_ext(md_file), '.html', sep = '')
markdownToHTML(md_file, html_file)

click "OK", "OK".

单击“确定”,“确定”。

3) back in your project, in the Project Explorer view, right click on the minimal.Rmd file, and select "Run Code Snippet in R -> Rmd2html"

3)返回项目,在Project Explorer视图中,右键单击minimal.Rmd文件,然后选择“在R中运行代码片段 - > Rmd2html”

This should generate the minimal.html file.

这应该生成minimal.html文件。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2012/09/12/dc8482a4a98227e55b0aedcc1121b964.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号