Samoth
Samoth

Reputation: 756

Unable to deploy the googleVis motion chart using R shiny server

The motion chart appeared well on my own computer although the chart shows up on the other IE window instead of RStudio's internal window. However, when I used the R Shiny server in order to deploy the googleVis motion chart on web, this error message shows:

  Error: $ operator is invalid for atomic vectors

I also checked them using the commands below and it shows they are not atomic:

  >is.recursive(Fruits)
  [1] TRUE
  >is.atomic(Fruits)
  [1] FALSE

Reproducible code is as below, I've simplifed it and use the internal data "fruit" to demo it; the problem is still there, the motion chart did not show in the same window but appear in another window in IE9. And when deployed using shiny-server, it become worses, motion chart did not appear at all and shows the same error message

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"))
  )
 )
 ) 
 )

Upvotes: 1

Views: 610

Answers (1)

Serhii
Serhii

Reputation: 422

You don't need plot function while rendering chart in renderGivs section. I have slightly modified server part of your code. When you run application you have to open it in a browser otherwise chart will not be shown.

library(shiny)
library(googleVis)

ui = shinyUI(fluidPage(
    titlePanel("Analysis"),
    mainPanel(
        navlistPanel(
            tabPanel("MotionChart",h1("Motion Chart"),tableOutput("motionchart2"))
        )
    )
))

server = shinyServer(function(input, output) {
    output$motionchart2 <- renderGvis({
        gvisMotionChart(Fruits, idvar="Fruit", timevar="Year")
    })
})

runApp(list(ui = ui, server = server))

Upvotes: 1

Related Questions