R,Shiny不能做rChart

时间:2015-10-04 02:26:01

标签: r shiny

在闪亮中使用hPlot(vs hist)是否有任何限制?我找不到有关在闪亮上使用rCharts内容的限制的任何信息。不确定我错过了什么。

我真的需要/想要使用hPlot来做更好的演示。

## ui.R
library(shiny)
library(rCharts)

shinyUI(fluidPage(
    titlePanel("Count Report "),
    h4("This application shows product data"),
    sidebarLayout(
      sidebarPanel(
        selectizeInput("product","Product:",c("ALPHA","BRAVO","all"), selected="all")
        ),

        mainPanel(
          h4("rChart Auuuuu??????!!!"),
          plotOutput("chart")

        )
    )
))


##---server.R
library(shiny)
library(rCharts)

shinyServer(
    function(input, output) {
      x <- data.frame(Category=factor(c("ALPHA", "ALPHA","BRAVO","ALPHA","ALPHA")), 
                      YYYYMM= factor(c("2/1/2015","3/1/2015","4/1/2015","5/1/2015","6/1/2015")),
                      COUNT=c(44,22,37,76,97))

        output$chart <- renderPlot({
          # generate an rnorm distribution and plot it
          #hist(x$COUNT)    ######### this works OK
          hPlot(COUNT ~ YYYYMM, data=x, type="line") ######### doesnt WORK!
        })
})

1 个答案:

答案 0 :(得分:1)

请注意我使用showOutput代替plotOutputrenderChart2代替renderPlot所做的更改,因为您需要进行*这些更改以使{{1}情节。您还需要在rChart中指定名称空间,我{ 认为 showOutput属于hplot,但我可能错了(如果有人知道肯定可以在这里发表评论,那么我可以更新答案)。有关使用highcharts的详细信息,请查看示例here on github

以下内容应该有效:

rCharts

enter image description here