Skip to content

Unable to find the "ojs_define" function in child qmd after v1.3.433 #6141

@Eugloh

Description

@Eugloh

Bug description

First of all, I'd like to thank you for Quarto and the features you've provided for the automated reports I use on a daily basis.

I'm currently setting up an interface to generate automated HTML analysis reports, such as a quality report.

My idea is to call .qmd children from a file according to the parameters specified in the interface.

but since I encountered the error #5762 and installed v1.3.433 I can no longer generate the OJS code for my report, "ojs_define" function is not found.

If I make it simpler and replace the call child chunk with the code present in q2.qmd the ojs is executed, but it won't be displayed when I reload my html file or try to move it.

Steps to reproduce

p1.qmd

---
params:
  analyse_type: "Quality Control"
format:
  html:
    code-fold: TRUE
    embed-resources: TRUE
title: |
  Analysis Type : `r params$analyse_type` Report
cache: FALSE
---

```{r}
nb_patients <- 15
nb_clusters <- 7
set.seed(1234)
abundance <- matrix(rnorm(nb_patients * nb_clusters), nrow = nb_patients, ncol = nb_clusters)
```

```{r , child="p2.qmd", eval =  {if(params$analyse_type=="Quality Control")TRUE else FALSE}  } 

```

p2.qmd

# Explore PCA


```{r}
abundance |> as.data.frame() |>
  dplyr::mutate_all(scale, center = TRUE) -> centered
pca <- stats::prcomp(centered) 
Table <- as.data.frame(predict(pca))
ojs_define(pcjs = Table)

```

::: {.panel-sidebar}
```{ojs}

ojs_pc = transpose(pcjs)
viewof pc1 = Inputs.select(Object.keys(ojs_pc[0]), {value: "PC1", multiple: false, label: "PC Axe 1"})
viewof pc2 = Inputs.select(Object.keys(ojs_pc[0]), {value: "PC2", multiple: false, label: "PC Axe 2"})

```
:::

::: {.panel-fill}
::: {.panel-tabset}
## Plot

```{ojs}
//| label: fig-pca-with-ojs
//| fig-cap: "Interactive pca plot"
//| panel: fill

Plot.plot({
  grid: true,
  inset: 10,
  x: {label: pc1},
  y: {label: pc2},
  marks: [
  Plot.frame(),
    Plot.dot(ojs_pc, {x: pc1, y: pc2})
  ]
})
```

## Data

```{ojs}
Inputs.table(ojs_pc)
```
:::
:::

Expected behavior

Previously, the ojs_define function worked even when it was in a child file, and the ojs output was self-contained in the html file.

Actual behavior

I am now getting :

processing file: p1.qmd
1/5                  
2/5 [unnamed-chunk-1]
3/5                  
4/5 [unnamed-chunk-2]


processing file: <path>/p2.qmd
1/9                  
2/9 [unnamed-chunk-3]



Quitting from lines 6-1 [unnamed-chunk-3] (<path>/p2.qmd)



Quitting from lines 1-19 [unnamed-chunk-2] (<path>/p2.qmd)
Error in `ojs_define()`:
! impossible de trouver la fonction "ojs_define"
Exécution arrêtée

Your environment

R version 4.2.2 Patched (2022-11-10 r83330)

Platform: x86_64-pc-linux-gnu (64-bit)

RStudio: 2023.06.0 Build 421

Quarto check output

quarto check

[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.2: OK
      Dart Sass version 1.55.0: OK
      Deno version 1.33.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.193
      Path: /opt/quarto/bin

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.10.6
      Path: /usr/bin/python3
      Jupyter: 4.9.1
      Kernels: julia-1.6, python3

(|) Checking Jupyter engine render....[IPKernelApp] WARNING | debugpy_stream undefined, debugging will not be enabled
[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.2.2
      Path: /usr/lib/R
      LibPaths:
        - /usr/local/lib/R/site-library
        - /usr/lib/R/site-library
        - /usr/lib/R/library
      knitr: 1.43
      rmarkdown: 2.22

[✓] Checking Knitr engine render......OK

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingengines-knitrAnything regarding knitr enginesojs-engineIssues with the ojs engine

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions