Question

Can someone explain me why i'm getting several 'points' at the same date when i click 'play'? Each date is unique, so it doesn't make sense to me.

My code is:

require(googleVis)
n = 100
dates = seq(Sys.Date(), by = 'day', length = n)
x = 10 * rnorm(n)
y = 3 * x + 1 + rnorm(n)
label = sample(LETTERS[1:4], size = n, replace = TRUE)

my.data = data.frame(Date = dates, x, y, label)
p = gvisMotionChart(my.data, idvar ='label', xvar = 'x', yvar = 'y', timevar= 'Date')
plot(p)

thanks!

Was it helpful?

Solution

You get one ball for each label (A,B,C,D). My guess is that it is interpolated in between the dates, you can also see this in how the balls move slowly for some dates. In order to have on ball you can obviously just have one label.

Edit. The values are interpolated for the date range that exist for each label. See the code below. The sequence of labels is {D, A, A, A, ..., A, B, ...B, C, .. C, D, .. D}. The D ball is shown all the time and is slowly interpolated between the first two values. The rest of the balls do not show up outside their range. Seems reasonable way to deal with missing values.

require(googleVis)
n = 100 
dates = seq(Sys.Date(), by = 'day', length = n)
x = 10 * rnorm(n)
label = rep(LETTERS[1:4], each=25)
label[1] = "D"

my.data = data.frame(Date = dates, x, y, label)
p = gvisMotionChart(my.data, idvar ='label', xvar = 'x', yvar = 'y', timevar= 'Date')
plot(p)

Edit 2. Realised I pasted in the original code snippet without my changes. Fixed now.

OTHER TIPS

svenski is right. Its the motion between points that is pictured on the googleVis graph. You will see multiple points as they are moving to the next label in your data.

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