Running examples in 'plot3Drgl-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: plotrgl
> ### Title: Plot 3D graphs in rgl window.
> ### Aliases: plotrgl
> ### Keywords: hplot
> 
> ### ** Examples
> 
> # save plotting parameters
>  pm <- par("mfrow")
>  pmar <- par("mar")
> 
> ## =======================================================================
> ## Composite image and contour in 3D
> ## =======================================================================
> # plot reduced resolution (for speed) volcano to traditional window: 
>  VV <- volcano[seq(1, nrow(volcano), by = 3), seq(1, ncol(volcano), by = 3)]
>  persp3D(z = VV, contour = list(side = "zmax"))
> 
>  plotrgl(new = TRUE) # new window
> 
> # add light, smooth surface change x-axis limits 
>  plotrgl(new = FALSE, lighting = TRUE, 
+    xlim = c(0.2, 0.8), smooth = TRUE)
> 
> # same:
> # persp3Drgl(z = volcano, contour = list(side = "zmax"), 
> #  lighting = TRUE, xlim = c(0.2, 0.8), smooth = TRUE)
>   
> ## =======================================================================
> ## scatters with fitted surface and droplines (see ?scatter3D)
> ## =======================================================================
> 
>  par (mfrow = c(1, 1))
>  with (mtcars, {
+ 
+   # linear regression
+    fit <- lm(mpg ~ wt + disp)
+ 
+   # predict values on regular xy grid
+    wt.pred <- seq(1.5, 5.5, length.out = 30)
+    disp.pred <- seq(71, 472, length.out = 30)
+    xy <- expand.grid(wt = wt.pred, 
+                      disp = disp.pred)
+ 
+    mpg.pred <- matrix (nrow = 30, ncol = 30, 
+       data = predict(fit, newdata = data.frame(xy), 
+       interval = "prediction"))
+ 
+ # fitted points for droplines to surface
+    fitpoints <- predict(fit) 
+ 
+    scatter3D(z = mpg, x = wt, y = disp, pch = 18, cex = 2, 
+       theta = 20, phi = 20, ticktype = "detailed",
+       xlab = "wt", ylab = "disp", zlab = "mpg",  
+       surf = list(x = wt.pred, y = disp.pred, z = mpg.pred, 
+                   facets = NA, fit = fitpoints),
+       main = "mtcars")
+   
+  })
Error in matrix(nrow = 30, ncol = 30, data = predict(fit, newdata = data.frame(xy),  : 
  data length differs from size of matrix: [2700 != 30 x 30]
Calls: with -> with.default -> eval -> eval -> matrix
Execution halted