-1

I am trying to make a 3d scatterplot using the cloud function (lattice package), however I am getting an error I am unable to debug.

In essence what I am trying to accomplish is see if there is any correlation among gas consumption (UK) versus driver deaths over time. Here is what I have so far:

gas <- UKgas
dd <- UKDriverDeaths
dd.zoo <- zoo(dd)
ddq <- aggregate(dd.zoo, as.yearqtr, mean)
gas2 <- window(UKgas, start = c(1969,1), end = c(1984,4))
gasdeathq <- list(x = gas2, y = ddq)

quarters.f <- factor(c(1,2,3,4),levels = c(1,2,3,4), labels = c("Q1","Q2","Q3","Q4"))
cloud(gasdeathq$y~gasdeathq$x*time(gasdeathq$x)|quarters.f, main="3D Scatterplot by Quarter")

When trying to plot this data I get the error: "Error using packet 3 indexes overlap"

user3689341
  • 143
  • 2
  • 11

1 Answers1

0

Ok got it working...was scratching my head as everything should have been working but I think it might be the time series/zoo class, so I got in working by coerces everything to a numeric vector first:

cloud(as.numeric(ddq)~as.numeric(gas2)*as.numeric(z)|quarters.f,xlab = "Gas consumption", ylab = "Year", zlab = "Driver deaths",main="3D Scatterplot by Quarter")

user3689341
  • 143
  • 2
  • 11