Question

I'm having issues getting GoogleVis to work. When I plot using GoogleVis, I get a blank browser. Here's what I did:

  1. I used the built-in R dataset, 'ChickWeight'
  2. Installed RJSONIO and googleVis packages.
  3. For simplicity, I truncated the ChickWeight dataframe to 24 rows: ChickWeight1<-ChickWeight[1:24,]
  4. Then called the gvisMotionChart function, assigning it an object: visualization1<-gvisMotionChart(ChickWeight1,idvar='weight',timevar='Time')
  5. Running the above code gave me a warning message. Not sure if warning message is related:

Warning message: In if (class(x[[.x]]) == "Date") as.character(x[[.x]]) else x[[.x]] : the condition has length > 1 and only the first element will be used

  1. I then plotted the object: plot(visualization1)

I expected a motion chart, but I just got a blank browser. I also tried converting the 'Time' column from a numeric to date class, but no luck.

I'm using R 3.0.2, Mac OS X version 10.6.8 and Safari Version 5.1.2 (6534.52.7). I also ran the the same code on my work Windows laptop, but no luck.

Any feedback would be greatly appreciated! Thanks!

Was it helpful?

Solution

The full error that you got after typing:

mchart1<-gvisMotionChart(ChickWeight1,idvar='weight',timevar='Time') was:

Error in gvisCheckMotionChartData(data, my.options) : The data must have rows with unique combinations of idvar and timevar. Your data has 578 rows, but idvar and timevar only define 375 unique rows. In addition: Warning message: In if (class(x[[.x]]) == "Date") as.character(x[[.x]]) else x[[.x]] : the condition has length > 1 and only the first element will be used

This error would have clued you in to the fact that you hadn't designated the ids of the chicks. If you do mchart1<-gvisMotionChart(ChickWeight,idvar='Chick',timevar='Time') This will give you the motion plot of how the chicks gain weight over time.

?gvisMotionChart is very useful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top