我输入了三维散点图的代码并收到以下错误:
Error in xyz.coords(x = x, y = y, z = z, xlab = xlabel, ylab = ylabel, : 'x', 'y' and 'z' lengths differ
输入的代码如下:
x <- rbinom(1000, 8, 0.5) y <- rbinom(1000, 8, 0.5) K <- c(rep(0:8,times = 9), rep(0:8, each = 9)) k <- matrix(k, ncol=2, byrow = FALSE) z <- k[,1]+k[,2] cdf <- rep(0.0, times = 81) for (i in 1:81) {cdf[i] <- sum(x+y <= z[i])/1000}
scatterplot3d(k[,1], k[,2], cdf, highlight.3d = TRUE, col.axis ="blue", main="Plotting Bivariate CDF", pch = 20, ylab = "Values of y", xlab = "Values of x", zlab = "CDF of x+y")
有没有人对如何解决这个错误有任何建议 - 我很困惑。