/
Rmd_test.Rmd
39 lines (31 loc) · 1.02 KB
/
Rmd_test.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
title: "Test"
author: "Changcheng Li"
date: "2017/9/23"
output: github_document
---
## Use JuliaCall as Julia Engine in R Markdown
To use `JuliaCall` package for julia engine in R Markdown document.
Just set the engine for julia to `JuliaCall::eng_juliacall` like this:
```{r setup}
knitr::knit_engines$set(julia = JuliaCall::eng_juliacall)
```
```{julia}
## This is a julia language chunk.
## In julia, the command without ending semicolon will trigger the display
## so is JuliaCall package.
## The julia display will follow immediately after the corresponding command
## just as the R code in R Markdown.
a = sqrt(2)
a = sqrt(2);
b = begin println(sqrt(2)); sqrt(2) end
```
## Get Access to Julia in R Chunk
And you can also get access to julia variables in R code chunk quite easily
using `JuliaCall`, for example:
```{r}
## This is a R language chunk.
## In the previous julia chunk, we define variable a,
## we can use functions in JuliaCall to get access to it.
JuliaCall::julia_eval("a") + JuliaCall::julia_eval("b")
```