【发布时间】:2016-09-19 21:51:57
【问题描述】:
我遇到了可怕的“$ 运算符对原子向量无效”错误。当我添加 gvisLineChart 时会发生这种情况。有什么建议吗?
library(shiny)
library(googleVis)
#this is a dput of a sql query to make the example reproducible.
#In reality this will be an RODBC sqlQuery result
dataset <- structure(list(id = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L),
value = c(1.68294196961579, 82.4641565111739, 83.3056274959818,
6.73176787846317, 5.89029689365528, 2.52441295442369, 4.20735492403948,
0.841470984807897, 5.04882590884738, 15.1464777265421)),
.Names = c("id", "value"), row.names = c(NA, 10L), class = "data.frame")
ui <- shinyUI(
plotOutput("motionPlot")
)
server <- shinyServer(function(input, output) {
output[["motionPlot"]] <- renderGvis({
Line <- gvisLineChart(dataset, xvar=c("id"), yvar=c("value"))
plot(Line)
})
})
shinyApp(ui = ui, server = server)
【问题讨论】:
-
没有reproducible example 很难提供帮助。听起来
dataset不是 data.frame,但我们无法运行您的代码来测试它。 -
我在这个例子中使用了 msdb 数据库,因此任何拥有 mssql db 的人都可以运行它。针对任何数据库的任何查询都将重现结果。不幸的是,这是一个与数据库相关的问题,因此“可重现”将包括对数据库的引用。感谢您的关注,感谢您的帮助。
-
我已经输入了 sqlQuery 结果以使其可重现。