8000 Code and output messed up in R Markdown after rgl plot · Issue #302 · dmurdoch/rgl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Code and output messed up in R Markdown after rgl plot #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and p AC00 rivacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dmurdoch opened this issue Jan 26, 2023 · 1 comment
Open

Code and output messed up in R Markdown after rgl plot #302

dmurdoch opened this issue Jan 26, 2023 · 1 comment

Comments

@dmurdoch
Copy link
Owner
dmurdoch commented Jan 26, 2023

If the chunk option has collapse = TRUE and any htmlwidget (including one from rgl) is displayed there, then code and output following the widget will not be formatted properly.

Problematically, the rmarkdown::html_vignette template defaults to collapse = TRUE.

This is a knitr issue, fixed in yihui/knitr#2212. That fix is included in knitr version 1.42.3, currently only on Github. You can install it with

remotes::install_github("yihui/knitr")
@dmurdoch
Copy link
Owner Author

A workaround if you want collapse = TRUE is to end any chunk at the point where it shows an rgl (or other htmlwidget) display, and start a new chunk afterwards. For example, change this:

```{r collapse = TRUE}
xyz <- matrix(rnorm(30), ncol = 3)
plot3d(xyz)
plot3d(xyz, type = "s")
```

to this:

```{r collapse = TRUE}
xyz <- matrix(rnorm(30), ncol = 3)
plot3d(xyz)
```
```{r collapse = TRUE}
plot3d(xyz, type = "s")
```

Another workaround is to use chunk option fig.show = "hold", which will display all the rgl figures after the chunk, instead of showing them as they are completed. For example,

```{r collapse = TRUE, fig.show = "hold"}
xyz <- matrix(rnorm(30), ncol = 3)
plot3d(xyz)
plot3d(xyz, type = "s")
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0