Error : incorrect number of dimensions

3 messages
Open this post in threaded view
|
Report Content as Inappropriate

Error : incorrect number of dimensions

 Hi all, I tried to run the following code, but at the end it says 'Error in k[, 1] : incorrect number of dimensions'. I just copy-paste this code and have no experience on programming.  Can any one tell me what's wrong and how to fix it? Thanks in advance! 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',               mian='Plotting bivariate CDF', pch = 20, ylab = 'values of y', xlab = 'values of x',               zlab = 'CDF of x+y')
Open this post in threaded view
|
Report Content as Inappropriate

Re: Error : incorrect number of dimensions

 I think you meant:z <- K[,1] + K[,2]The capital "K" is the matrix, not the lower case "k".Jim HoltmanData Munger Guru What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it. On Fri, Mar 17, 2017 at 7:39 AM, white1551 wrote:Hi all, I tried to run the following code, but at the end it says 'Error in k[, 1] : incorrect number of dimensions'. I just copy-paste this code and have no experience on programming.  Can any one tell me what's wrong and how to fix it? Thanks in advance! *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',               mian='Plotting bivariate CDF', pch = 20, ylab = 'values of y', xlab = 'values of x',               zlab = 'CDF of x+y')* -- View this message in context: http://r.789695.n4.nabble.com/Error-incorrect-number-of-dimensions-tp4729807.html Sent from the datatable-help mailing list archive at Nabble.com. _______________________________________________ datatable-help mailing list [hidden email] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help _______________________________________________ datatable-help mailing list [hidden email] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help