[datatable-help] Error : incorrect number of dimensions

jim holtman jholtman at gmail.com
Fri Mar 17 13:09:22 CET 2017


I think you meant:

z <- K[,1] + K[,2]

The capital "K" is the matrix, not the lower case "k".


Jim Holtman
Data 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 <743642404 at qq.com> 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
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/
> listinfo/datatable-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20170317/f2308d86/attachment.html>


More information about the datatable-help mailing list