-
Hi, I'm loading some data in a Julia cell and was wondering if I can share such a data object with R or Observable cells? I know there is a function that allows sharing data from R and Python to Observable, but is there something similar for Julia? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 12 replies
-
same function name, |
Beta Was this translation helpful? Give feedback.
-
On additional note, Quarto supports knitr to run the R chunks and R / knitr ecosystem have tools for multi language, like JuliaCall So when using R with Quarto doc, you can use JuliaCall engine to run some Julia, then use a R chunk to retrieve some Julia variable, and possibly pass it to OJS using This is using all knitr computation engine from Quarto perspective. This gave me the opportunity to test it quickly. Here is an example which requires R, JuliaCall R package, a Julia installation on PATH. ---
title: Julia R and Observable
format: html
engine: knitr
---
R chunk with value passed to OJS
```{r}
a <- 1
a
ojs_define(a = a)
```
Julia chunk that will be executed with Julia through JuliaCall R package
```{julia}
b = 2
```
Using R chunk to retrieve value computed in Julia and pass it to OJS
```{r}
ojs_define(b = JuliaCall::julia_eval("b"))
```
Computing in OJS using value define in R and Julia
```{ojs}
a + b
``` This shows this is possible. :) Python could even be added through the use of reticulate R package |
Beta Was this translation helpful? Give feedback.
-
If you are willing to store your data in an external file, I also recommend using an Apache Arrow file as an intermediate format. https://quarto.org/docs/interactive/ojs/data-sources.html#file-attachments ```{r}
arrow::write_feather(
mtcars,
"data.arrow",
compression = "uncompressed"
)
```
```{ojs}
data = FileAttachment("data.arrow").arrow()
``` Arrow files are also richer in data types, which may allow for more accurate type conversion when exchanging data between languages. |
Beta Was this translation helpful? Give feedback.
On additional note, Quarto supports knitr to run the R chunks and R / knitr ecosystem have tools for multi language, like JuliaCall
So when using R with Quarto doc, you can use JuliaCall engine to run some Julia, then use a R chunk to retrieve some Julia variable, and possibly pass it to OJS using
ojs_define
.This is using all knitr computation engine from Quarto perspective. This gave me the opportunity to test it quickly. Here is an example which requires R, JuliaCall R package, a Julia installation on PATH.