将MATLAB脚本集成到R Markdown文档中

时间:2014-05-08 09:43:32

标签: r matlab knitr r-markdown

我想将一些旧的matlab脚本集成到我的论文的.Rmd文档中,以避免编织者试图避免的复制粘贴。这可能吗?使用http://yihui.name/knitr/demo/engines/我能够集成python代码没问题,但是matlab要困难得多。

2 个答案:

答案 0 :(得分:6)

knitr已更新,实际版本1.15.1允许更多支持的引擎:octave就是其中之一:

library(knitr)
names(knit_engines$get())

 [1] "awk"       "bash"      "coffee"    "gawk"      "groovy"   
 [6] "haskell"   "lein"      "mysql"     "node"      "octave"   
[11] "perl"      "psql"      "python"    "Rscript"   "ruby"     
[16] "sas"       "scala"     "sed"       "sh"        "stata"    
[21] "zsh"       "highlight" "Rcpp"      "tikz"      "dot"      
[26] "c"         "fortran"   "fortran95" "asy"       "cat"      
[31] "asis"      "stan"      "block"     "block2"    "js"       
[36] "css"       "sql" 

要在Rmarkdown笔记本中添加八度代码,请使用:

```{octave}
# Insert your octave code here
```

答案 1 :(得分:3)

knitr目前支持的引擎是

> require(knitr);
names(knit_engines$get())
 [1] "awk"       "bash"      "coffee"    "gawk"      "haskell"   "perl"      "python"    "Rscript"    "ruby"      "sas"      
[11] "sed"       "sh"        "zsh"       "highlight" "Rcpp"      "tikz"      "dot"       "c"         "asy"       "cat"

所以是的,matlab目前不支持作为knitr引擎,但也许这个(Convert MATLAB code to R)可以帮助将matlab代码移植到R