简体   繁体   English

带有rsconnect包的rgl包

[英]rgl package with rsconnect package

I encounter some problem when using the rgl package to plot a 3D picture on shinyR. 使用rgl软件包在ShinyR上绘制3D图片时遇到一些问题。 My code works without error or problem on the local Rstudio. 我的代码在本地Rstudio上运行时没有错误或问题。 The 3D plot does really show up just as I expected. 3D图确实确实如我预期的那样显示。 However, whenever I publish it to shinyapps.io through rsconnect package, the 3D plot does not show up on the website. 但是,每当我通过rsconnect软件包将其发布到Shinyapps.io时,该3D图都不会显示在网站上。 Simultaneously, no error occurs. 同时,没有错误发生。 This confuses me a lot. 这让我很困惑。 I look for the solution on the internet and upload a simple example to test. 我在互联网上寻找解决方案,并上传了一个简单的示例进行测试。 Here is the code: 这是代码:

library(shiny)
library(rgl)
library(rglwidget)
options(rgl.useNULL=TRUE) 
open3d(useNULL = TRUE) 
ids <- plot3d(rnorm(100), rnorm(100), rnorm(100))[1] 
scene <- scene3d() 
rgl.close() 
ui <- (fluidPage(
  checkboxInput("chk", label = "Display", value = FALSE),
  rglwidgetOutput("wdg")
))
server <- function(input, output, session) {
  options(rgl.useNULL = TRUE)
  save <- options(rgl.inShiny = TRUE)
  on.exit(options(save))
  output$wdg <- renderRglwidget({
    rglwidget(scene)
  })
}
if (interactive())
  shinyApp(ui = ui, server = server)

Finally, there is error message: 最后,出现错误信息:

Warning in rgl.init(initValue, onlyNULL) : rgl.init(initValue,onlyNULL)中的警告:
RGL: unable to open X11 display RGL:无法打开X11显示屏
Warning: 'rgl_init' failed, running with rgl.useNULL = TRUE 警告:“ rgl_init”失败,使用rgl.useNULL = TRUE运行
The functions in the rglwidget package have been moved to rgl. rglwidget软件包中的功能已移至rgl。
Attaching package: 'rglwidget' 附件包:“ rglwidget”
The following objects are masked from 'package:rgl': 以下对象被'package:rgl'屏蔽:
playwidget, rglwidget playwidget,rglwidget
Error in value[3L] : app.R did not return a shiny.appobj object. value [3L]错误:app.R未返回Shiny.appobj对象。
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> 调用:本地... tryCatch-> tryCatchList-> tryCatchOne->

As you can see, the error message mentions “X11”, I google this only to find all these X11 problems are related to ubanto or mac environment (mine is win10 ). 如您所见,错误消息中提到了“ X11”,我在Google上搜索这所有X11问题均与ubanto或mac环境(mine为win10)有关。 Therefore, I couldn't find useful answer. 因此,我找不到有用的答案。 I have also tried the capabilities() function but the result just says my X11 is False. 我也尝试过capabilities()函数,但结果只是说我的X11是False。 I could not figure out which part went wrong and hence I list all my information. 我无法弄清楚哪一部分出错了,因此我列出了所有信息。
Great thanks if anyone can help or provide further information. 非常感谢任何人可以提供帮助或提供更多信息。

You shouldn't use the rglwidget package; 您不应该使用rglwidget包; it is obsolete. 它已经过时了。

The warnings about X11 are coming because you're trying to set up a local window on the Shiny server. 有关X11的警告即将到来,因为您正在尝试在Shiny服务器上设置本地窗口。 To avoid doing that, use options(rgl.useNULL = TRUE) before library(rgl) . 为避免这样做,请 library(rgl) 之前使用options(rgl.useNULL = TRUE) library(rgl) If you do this, it won't be necessary in the open3d call. 如果执行此操作,则在open3d调用中将open3d

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM