我已经为几个小规模的项目使用了闪亮,现在我正在尝试闪光仪表板包,它看上去相当有希望。我还想用巧妙的方式集成交互情节(尽管将来还可以考虑其他库)。
我没有问题在示例中巧妙地集成示例,但是当尝试使用shinydashboard实现类似的结果时,我会遇到问题。
例如,下面的代码(app.R)不能正常工作。
library(shiny)
library(shinydashboard)
library(plotly)
library(ggplot2)
data(movies, package = "ggplot2")
minx <- min(movies$rating)
maxx <- max(movies$rating)
#######
####### UI
#######
ui <- dashboardPage(
############# Header
dashboardHeader(title = "Test"),
############# Sidebar
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"))
)
),
############# Dashboard body
dashboardBody(
# Boxes need to be put in a row (or column)
fluidRow(
box(plotOutput("plot1"), width=6, height=500),
box(plotOutput("plot2"), width=6, height=500)
)
)
)
#######
####### Server
#######
server <- function(input, output, session) {
output$plot1 <- renderPlot({
# a simple histogram of movie ratings
p <- plot_ly(movies, x = rating, autobinx = F, type = "histogram",
xbins = list(start = minx, end = maxx, size = 2))
# style the xaxis
layout(p, xaxis = list(title = "Ratings", range = c(minx, maxx), autorange = F,
autotick = F, tick0 = minx, dtick = 2))
})
output$plot2 <- renderPlot({
hist(movies$rating, col="blue")
})
}
shinyApp(ui, server)该页面应该显示两个类似的情节:一个是用巧妙的方式生成的,另一个是用R基生成的。第二个是正确显示的,但在Rstudio查看器面板中显示的是巧妙的。如果我使用runApp()函数在终端上运行该应用程序,则会打开一个用于仪表板的网页,另一个仅用于巧妙的交互情节。
我尝试创建一些反应性的绘图(改变一些闪亮控件(如幻灯片条)的内容的功能),并且在查看器或另一个浏览器窗口/选项卡中打开的地块将被更新。所以一切看起来都正常,唯一的问题是,这个情节并不是插入在仪表板上,而是插入到另一个位置(查看器或其他选项卡),这当然是个问题。
尽管我进行了研究,但我还是找不到解决问题的办法(甚至有人提到这个问题.)。有线索吗?
发布于 2015-11-26 14:43:06
再次检查教程,我认为您需要在ui中替换
box(plotOutput("plot1"), width=6, height=500)通过
box(plotlyOutput("plot1"), width=6, height=500)而在server中只需替换
output$plot1 <- renderPlot({
......通过
output$plot1 <- renderPlotly({
....https://stackoverflow.com/questions/33941232
复制相似问题