Since I found nothing on the web about the engine scilab in knitr, I tried to integrate it according to the code given in those two links http://www.tuicool.com/articles/B3emui and https://github.com/yihui/knitr/pull/294/files. I wrote the rmarkdown code below :
---
title: "scilab in knitr"
author: "Laurent"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(stringr)
```
```{r,eval=TRUE}
eng_scilab <- function(options) {
code <- str_c(options$code, collapse = '\n')
if (options$eval) {
cmd <- sprintf('d:\\programfiles\\scilab-5.5.2\\bin\\scilex -nw -e %s',
shQuote(code,type="cmd"))
out <- system(cmd, intern = TRUE)
}else{out <- "output when eval=FALSE and engine='scilab'"}
knitr::engine_output(options, options$code, out)
}
knitr::knit_engines$set(scilab=eng_scilab)
```
```{r scilab,engine="scilab",eval=TRUE}
data1 = [10 2 8 3];
disp(data1);
quit;
```
```{r scilabcall}
code <- "data1 = [10 2 8 3];disp(data1);quit;"
cmd <- sprintf('d:\\programfiles\\scilab-5.5.2\\bin\\scilex -nw -e %s',
shQuote(code,type="cmd"))
out <- system(cmd, intern = TRUE)
out
```
This last chunk is to control that the system call works. The variable out contains:
## [1] "Scilab 5.5.2 (Mar 31 2015, 12:04:21)"
## [2] " "
## [3] " 10. 2. 8. 3. "
and when I put eval=FALSE for the chunk "scilab" I have correctly the message "output when eval=FALSE and engine='scilab'" from the eng_scilab function. But when I put eval=TRUE nothing appends, the code is stuck in the chunk "scilab". Could someone give me some pointers to go on ? Thanks