I want to make the following case of linear regression in R
year<-rep(2008:2010,each=4)
quarter<-rep(1:4,3)
cpi<-c(162.2,164.6,166.5,166.0,166.4,167
Humbug. These are all reasonable solutions, but they don't do what you ask for. Now what you ask for is slightly cooler and completely impractical, but can be done using rgl.
f <- function(x, y, coefs){
z <- coefs[1] + coefs[2] * x + coefs[3] * y
z
}
x <- seq(from=min(year), to=max(year), length.out=100)
y <- seq(from=min(quarter), to=max(quarter), length.out=100)
z <- outer(x, y, f, coefs=coef(fit))
Now where the magic happens in rgl:
library(rgl)
persp3d(x, y, z, col="lightblue")

It isn't done justice here, but it's pretty and you can move it about.
And what the hell, let's add your original points
points3d(year, quarter, cpi, size=5, col="red")
