RMarkdown 八度图

发布于 2025-01-14 19:11:29 字数 286 浏览 2 评论 0原文

当使用 Octave 作为其引擎时,RMarkdown 可以生成绘图吗?这是一个基本示例:

```{octave}
plot([1,2,3])
```

在 CoCalc 中,就像在 Octave 和 MATLAB 中一样,输出将是一个绘图。同样,当在 RMarkdown 中使用 R 引擎时,

```{r}
plot(c(1,2,3))
```

我希望能够在 RMarkdown 中为 Octave 执行此操作 - 有解决方案吗?

Can RMarkdown produce plots when using Octave for its engine? Here's a basic example:

```{octave}
plot([1,2,3])
```

In CoCalc, as in Octave and MATLAB, the output would be a plot. Similarly, when using the R engine in RMarkdown for

```{r}
plot(c(1,2,3))
```

I would like to be able to do this for Octave in RMarkdown - is there a solution for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街角迷惘 2025-01-21 19:11:29

Octave 的函数绘图不返回图像,而是打开一个窗口。这就是为什么它默认也不能在 R Studio Server 上工作。以下是使用 print() 并随后显示图像的解决方法:

---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(
  echo = TRUE,
  engine.path = list(
    octave = "/usr/bin/octave"
  )
)
```

```{octave}
plot([1,2,3])

print("file.png")
```

![](file.png)

在此处输入图像描述

Octave's function plot does not return an image, but opens a window instead. This is why it also doesn't work on R Studio Server by default. Here is a workaround by using print() and displaying the image afterwards:

---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(
  echo = TRUE,
  engine.path = list(
    octave = "/usr/bin/octave"
  )
)
```

```{octave}
plot([1,2,3])

print("file.png")
```

![](file.png)

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文