【问题标题】:Error in grobToDev.default(gTree, dev)grobToDev.default(gTree,dev)中的错误
【发布时间】:2013-06-19 18:19:24
【问题描述】:

我正在尝试使用 shiny+gridSVG 构建应用程序。这个问题经常发生,我不知道。

我的服务器.R:

library(grid)
library(lattice)
library(gridSVG)

shinyServer(function(input, output) {

  data = reactive({
    inFile = input$file1
    if (is.null(inFile))
      return(NULL)
    read.csv(inFile$datapath, header=input$header, 
             sep=input$sep, quote=input$quote)
  })

  featurelist = reactive({
    return (colnames(data()))
  })

  output$classUI = renderUI({
    selectInput("classlabel","Classify by:", featurelist())
  })


  output$svg.grid = reactive({
    dat = data()
    features = featurelist()

    #group = dat[,c(which(features == input$classlabel))]
    subsetted.features = features[-c(which(features == input$classlabel))]

    #classlabel.level = levels(group)

    xyplot.out = xyplot(subsetted.features[1] ~ subsetted.features[2]|input$classlabel,
                        data = dat
                        )

    tempsvg <- tempfile(fileext=".svg")
    on.exit(unlink(tempsvg))
    gridToSVG(name=tempsvg)
    svgoutput <- readLines(tempsvg, n=-1)
    svgoutput
  })

})

这是我的 js:

<script>
var networkOutputBinding = new Shiny.OutputBinding();
$.extend(networkOutputBinding, {
    find: function(scope) {
      return $(scope).find('.shiny-network-output');
    },
    renderValue: function(el, data) {
          $(el).html(data.join(''));      
    }
  });
  Shiny.outputBindings.register(networkOutputBinding, 'timelyportfolio.networkbinding');

</script>

并且控制台中的错误信息是:

Error in grobToDev.default(gTree, dev) : We shouldn't be here!

有人知道原因吗?

【问题讨论】:

    标签: rstudio-server shiny-server


    【解决方案1】:

    我无法解释原因,但我收到了相同的错误消息并通过执行以下操作解决了它:

    • 退出 RStudio。
    • 更新到最新版本的 R(在我的例子中是 3.2)
    • 重新启动 RStudio
    • 重新安装 gridSVG 包

    问题消失了。

    顺便说一句:这是重新安装软件包的好方法:http://www.r-bloggers.com/automated-re-install-of-packages-for-r-3-0/

    【讨论】:

      【解决方案2】:

      我也遇到了这个问题(不是闪亮的;我只是想将绘图导出到 SVG),我不知道为什么——但对我来说,只有当我在我的内部调用 grid.export 时才会发生这种情况脚本。如果我重新显示我的情节并再次以交互方式调用它,它运行良好。我想这其中有某种环境差异?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-09
        • 2012-07-23
        • 2018-11-17
        • 1970-01-01
        • 1970-01-01
        • 2011-05-16
        相关资源
        最近更新 更多