3d scatter plot error

Hi everyone,
I am trying to create the 3d plot and my command is like below

LCMS = read.csv("LCMS.reduced.csv")
LCMS
x = rnorm(100)
y = rnorm(100)
z = x+y+rnorm(100,sd=.1)
x = (x - mean(x))/sd(x)
y = (y - mean(y))/sd(y)
z = (z - mean(z))/sd(y)
dat = cbind(x,y,z)
smallex = prcomp(dat, scale = TRUE)
screeplot(smallex, main = "Screeplot of smallex", xlab = "component")
names(smallex)
smallex$scale
plot(smallex$x[,1:2])
smallex$sdev
apply(smallex$x,2,sd)
screeplot(smallex)
scat = scatterplot3d(dat)
scat$points3d(t((smallex$rotation[,1:2])%*%t(smallex$x[,1:2])),col=2)
scat$points3d(rbind(c(0,0,0),smallex$rotation[,1]*10),type='1', col=3)

and they give out the error notice:
Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet

  1. plot.xy(xy.coords(x, y), type = type, ...)

  2. points.default(x, y, type = type, ...)

  3. points(x, y, type = type, ...)

  4. scat$points3d(rbind(c(0, 0, 0), smallex$rotation[, 1] * 10), type = "1", col = 3)
    type or paste code here

Could anyone tell me where  the mistake is please?
Thanks

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.