Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a dataframe created in an R code chunk in an ojs code chunk?

I wonder if there is any chance to use a dataframe created "on the fly" in the quarto document in an observable (ojs) chunk, instead of maybe writing it out as CSV and reading it in?

So something like this:

df = data.frame(
  x = 1:10,
  y = 2:11
)
{
 // somehow get access to the df
}
like image 754
Lenn Avatar asked Jun 24 '26 04:06

Lenn


1 Answers

Use the ojs_define() function to make data processed in Python or R available to {ojs} cells (this function should be called in the R or Python cell).

See more here in the Quarto Documentation.

like image 146
Arthur Avatar answered Jun 26 '26 18:06

Arthur