1

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"))
  )
 )
 ) 
 )
micstr
  • 5,080
  • 8
  • 48
  • 76
Samoth
  • 716
  • 15
  • 34
  • can you post the whole code, or at least enough to make a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) ? – tospig Oct 07 '15 at 10:37
  • @tospig: I added the reproducible code below, thanks for your advice. – Samoth Oct 08 '15 at 00:45
  • renderGvis, I believe, needs to be outputed as HTML, so in your UI, replace tableOutput with htmlOutput("motionchart2"). Can you also try replacing plot(M1) with return(M1) ? – Bogdan Rau Oct 12 '15 at 16:54
  • @BogdanRau: Sorry I also give it a try by using "return" and "htmloutput" but still in vain, thanks any way. – Samoth Oct 13 '15 at 08:07

1 Answers1

1

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))
Serhii
  • 362
  • 4
  • 15