【发布时间】:2015-10-07 08:43:11
【问题描述】:
动态图表在我自己的计算机上显示得很好,虽然图表显示在另一个 IE 窗口而不是 RStudio 的内部窗口上。 但是,当我使用 R Shiny 服务器在 Web 上部署 googleVis 动态图表时,此错误消息显示:
Error: $ operator is invalid for atomic vectors
我还使用以下命令检查了它们,结果表明它们不是原子的:
>is.recursive(Fruits)
[1] TRUE
>is.atomic(Fruits)
[1] FALSE
可复现的代码如下,我已经简化并使用内部数据“水果”来演示它;问题依然存在,IE9 的动态图表没有显示在同一个窗口中,而是出现在另一个窗口中。 而当使用shiny-server部署时,情况变得更糟,运动图表根本没有出现并显示相同的错误消息
服务器。 R
library(googleVis)
library(shiny)
shinyServer(function(input, output) {
output$motionchart2 <- renderGvis({
M1 <- gvisMotionChart(Fruits, idvar="Fruit", timevar="Year")
plot(M1)
})
})
UI.R
library(shiny)
library(googleVis)
shinyUI(fluidPage(
titlePanel("Analysis"),
mainPanel(
navlistPanel(
tabPanel("MotionChart",h1("Motion Chart"),tableOutput("motionchart2"))
)
)
)
)
【问题讨论】:
-
你能发布整个代码,或者至少足以制作一个reproducible example 吗?
-
@tospig:我在下面添加了可重现的代码,感谢您的建议。
-
我相信 renderGvis 需要输出为 HTML,因此在您的 UI 中,将 tableOutput 替换为 htmlOutput("motionchart2")。你也可以尝试用 return(M1) 替换 plot(M1) 吗?
-
@BogdanRau:对不起,我也尝试使用“return”和“htmloutput”,但仍然无效,谢谢。