You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Quarto R ojs_define function and OJS in RStudio #1242
I tried to use Quarto to do data preprocessing in R and then make the created data available in OJS using RStudio, but it seems to me that the ojs_define function is not available. This article suggests that it might be possible, but it does not seem to be working for me.
{r}
#| output: false
ojs_define(mtcars = mtcars)
In addition, it seems that using ojs from RStudio does not seem to be possible either. For example, following results in an error:
Thanks a lot. Using some features of OJS (e.g. Inputs.range) is working with the complete render now, but when I try to define data in R, and then use it with OJS, it gives me OJS Runtime Error invalid module. In fact even with OJS defined data, it does not seem to be working. The following code gives OJS Runtime Error invalid module.
I am sorry, but I have to reopen the issue. Below is a reprex. I can successfully define df in R. I can use the df in OJS, but I can't use the Plot module in RStudio. Is there a way to do that?
Ok, I see the issue. When using OJS, it's likely that you will run into modules that use modern JS syntax (such as the nullish coalescing operator ??). These are unfortunately not available in the QtWebEngine version of RStudio, which uses a quite-old version of Chromium.
2022-06-30T21:56:31.502192Z [rsession-novot] ERROR system error 22 (The device does not recognize the command); OCCURRED AT class rstudio::core::Error __cdecl rstudio::core::crash_handler::initialize(enum rstudio::core::crash_handler::ProgramMode) src/cpp/core/CrashHandler.cpp:358; LOGGED FROM: int __cdecl main(int,char *const []) C:\Users\jenkins\workspace\ide\open-source-pipeline\spotted-wakerobin\src\cpp\session\SessionMain.cpp:2007
2022-06-30T21:56:31.507184Z [rsession-novot] ERROR system error 22 (The device does not recognize the command); OCCURRED AT class rstudio::core::Error __cdecl rstudio::core::crash_handler::initialize(enum rstudio::core::crash_handler::ProgramMode) src/cpp/core/CrashHandler.cpp:358; LOGGED FROM: int __cdecl main(int,char *const []) C:\Users\jenkins\workspace\ide\open-source-pipeline\spotted-wakerobin\src\cpp\session\SessionMain.cpp:2057
2022-06-30T21:56:31.507184Z [rsession-novot] ERROR system error 22 (The device does not recognize the command); OCCURRED AT class rstudio::core::Error __cdecl rstudio::core::crash_handler::initialize(enum rstudio::core::crash_handler::ProgramMode) src/cpp/core/CrashHandler.cpp:358; LOGGED FROM: int __cdecl main(int,char *const []) C:\Users\jenkins\workspace\ide\open-source-pipeline\spotted-wakerobin\src\cpp\session\SessionMain.cpp:2057
Yes, I get the exact same behavior with the Quarto penguins example, almost two months later. RStudio 2022.07.1 Build 554, Windows 11. The issue is with the reactive plot in the Viewer with a rendered document. As noted above, it works fine in a browser (Microsoft Edge) after "Show in new window". A fresh install of RStudio on Linux gives the same error as on Windows. However, the viewer in Visual Studio Code works fine with both jupyter and r engines.
A reactive table works perfectly in the RStudio Viewer , so the problem is localized to the reactive plot in RStudio Viewer.
Thus, the penguins example in the Quarto docs will still fail for many users due to this issue. Another problem that is noted in a separate previous issue is that the example uses an altered version of the penguins.csv, but there is no link to download the custom file. This still has not been resolved, and the Quarto docs haven't been updated to reflect these known issues.
Can Quarto users somehow recommend to the Quarto team what to add to the documentation? Also, I fell like it would be best to close this issue and open a new one since my initial description is chaotic, which may confuse other users that encounter the issues mentioned above.
I have the same problem. I downloaded the latest version of Rstudio, Quarto and R but I also get the Error in ojs_define(x) : could not find function "ojs_define". Same error occurs in VS code.
---
title: "Untitled"
format: html
editor: visual
---
```{r}
#| echo: false
x = 2 * 2
ojs_define(x)
```
Error in ojs_define(x) : could not find function "ojs_define"`
Session.info:
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.5.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.2.1 tools_4.2.1 rstudioapi_0.14 knitr_1.40 xfun_0.33
That function won't work if you execute it as part of just a cell (as it's only available during a render). This is a limitation we definitely hope to overcome at some point but for now that's the deal.
Agreed!
This issue should not have the "needs-repro", thus the "stale" label.
Removing both now.
(Note, that I inadvertently added the stale message/label myself when reviewing all "needs-repro" issues.)
Also adding the "enhancement" label which is the proper label for feature requests.
Activity
jjallaire commentedon Jun 29, 2022
ojs doesn’t currently work interactively within RStudio (you have to do a complete render). This will be improved in the future!
novotny1akub commentedon Jun 29, 2022
Thanks a lot. Using some features of OJS (e.g. Inputs.range) is working with the complete render now, but when I try to define data in R, and then use it with OJS, it gives me OJS Runtime Error invalid module. In fact even with OJS defined data, it does not seem to be working. The following code gives OJS Runtime Error invalid module.
cscheid commentedon Jun 29, 2022
I can't reproduce this locally on the latest Quarto version. Can you make sure you're running an up-to-date version?
novotny1akub commentedon Jun 29, 2022
After updating my version, it seems to be working. Sorry for the confusion and thanks.
novotny1akub commentedon Jun 29, 2022
I am sorry, but I have to reopen the issue. Below is a reprex. I can successfully define df in R. I can use the df in OJS, but I can't use the Plot module in RStudio. Is there a way to do that?
cscheid commentedon Jun 29, 2022
Unfortunately, like jjallaire said, OJS plots in the "Plots" tab are not currently supported in RStudio.
I will note, though, that you can still render the entire document to get this:
6 remaining items
cscheid commentedon Jun 30, 2022
Ok, I see the issue. When using OJS, it's likely that you will run into modules that use modern JS syntax (such as the nullish coalescing operator
??). These are unfortunately not available in the QtWebEngine version of RStudio, which uses a quite-old version of Chromium.Can you try using the Electron dailies instead? They're at the rightmost column of https://dailies.rstudio.com/
novotny1akub commentedon Jun 30, 2022
Thanks for the explanation, now I get it. I am afraid neither the Electron version is working.
R Session Startup Failure Report
RStudio Version
RStudio 2022.07.0+547 "Spotted Wakerobin " (ec7dc45b, 2022-06-30) for Windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2022.07.0+547 Chrome/102.0.5005.63 Electron/19.0.4 Safari/537.36
Error message
[No error available]
Process Output
The R session exited with code 1.
Error output:
Standard output:
Logs
C:/Users/novot/AppData/Local/RStudio/log/rsession-novot.log
cscheid commentedon Jun 30, 2022
I've contacted the IDE devs and will report back.
elbert5770 commentedon Aug 24, 2022
Yes, I get the exact same behavior with the Quarto penguins example, almost two months later. RStudio 2022.07.1 Build 554, Windows 11. The issue is with the reactive plot in the Viewer with a rendered document. As noted above, it works fine in a browser (Microsoft Edge) after "Show in new window". A fresh install of RStudio on Linux gives the same error as on Windows. However, the viewer in Visual Studio Code works fine with both jupyter and r engines.
A reactive table works perfectly in the RStudio Viewer , so the problem is localized to the reactive plot in RStudio Viewer.
Thus, the penguins example in the Quarto docs will still fail for many users due to this issue. Another problem that is noted in a separate previous issue is that the example uses an altered version of the penguins.csv, but there is no link to download the custom file. This still has not been resolved, and the Quarto docs haven't been updated to reflect these known issues.
cscheid commentedon Aug 24, 2022
@elbert5770 I'm sorry you hit this issue too. This is a combination of Observable JS source (which we don't control) and RStudio IDE (which has a different release schedule), and as a result it's outside the control of the quarto project. Please report this as an RStudio IDE bug at https://github.com/rstudio/rstudio.
novotny1akub commentedon Aug 24, 2022
Can Quarto users somehow recommend to the Quarto team what to add to the documentation? Also, I fell like it would be best to close this issue and open a new one since my initial description is chaotic, which may confuse other users that encounter the issues mentioned above.
nvelden commentedon Oct 13, 2022
I have the same problem. I downloaded the latest version of Rstudio, Quarto and R but I also get the
Error in ojs_define(x) : could not find function "ojs_define". Same error occurs in VS code.Session.info:
jjallaire commentedon Oct 13, 2022
That function won't work if you execute it as part of just a cell (as it's only available during a render). This is a limitation we definitely hope to overcome at some point but for now that's the deal.
mcanouil commentedon Jun 12, 2023
jjallaire commentedon Jun 12, 2023
@mcanouil this is also not stale as it's a feature request. Let's re-open and remove the stale tag
mcanouil commentedon Jun 12, 2023
Agreed!
This issue should not have the "needs-repro", thus the "stale" label.
Removing both now.
(Note, that I inadvertently added the stale message/label myself when reviewing all "needs-repro" issues.)
Also adding the "enhancement" label which is the proper label for feature requests.