我认为下面的 R Markdown (Rmd) 代码应该生成一个嵌入了曲面图的 html 文档。
```{r, plotly=TRUE}
library(plotly)
py <- plotly()
x_vec = c(seq(-5, 4.9, 0.1))
x_matrix = matrix(c(x_vec), nrow = 100, ncol = 1)
y_matrix = matrix(c(x_vec), nrow = 1, ncol = 100)
data <- list(
x = x_vec,
y = x_vec,
z = matrix(c(cos(x_matrix %*% y_matrix) + sin(x_matrix %*% y_matrix)), nrow = 100, ncol = 100),
type = "surface")
layout <- list(
title = "Waaaves in r",
scene = list(bgcolor = "rgb(244, 244, 248)"))
response <- py$plotly(data, session="knitr",
kwargs = list(
layout = layout,
world_readable=FALSE,
filename = "waves example",
fileopt = "overwrite"))
```
该文档使用嵌入的代码创建输出,但没有绘图。只是一条错误消息说,
“呃哦,服务器出错了。”
知道这里发生了什么吗?