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"