<div dir="ltr"><div>I think you meant:</div><div><br></div><div>z <- K[,1] + K[,2]</div><div><br></div><div>The capital "K" is the matrix, not the lower case "k".</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><br>Jim Holtman<br>Data Munger Guru<br> <br>What is the problem that you are trying to solve?<br>Tell me what you want to do, not how you want to do it.</div></div>
<br><div class="gmail_quote">On Fri, Mar 17, 2017 at 7:39 AM, white1551 <span dir="ltr"><<a href="mailto:743642404@qq.com" target="_blank">743642404@qq.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I tried to run the following code, but at the end it says 'Error in k[, 1] :<br>
incorrect number of dimensions'. I just copy-paste this code and have no<br>
experience on programming. Can any one tell me what's wrong and how to fix<br>
it? Thanks in advance!<br>
<br>
*x <- rbinom(1000, 8, 0.5)<br>
y <- rbinom(1000, 8, 0.5)<br>
<br>
k <- c(rep(0:8, times=9), rep(0:8, each=9))<br>
K <- matrix(k, ncol = 2, byrow = FALSE)<br>
z <- k[, 1] + k[, 2]<br>
<br>
cdf <- rep(0.0, times = 81)<br>
<br>
for(i in 1:81) {cdf[i] <- sum(x+y <= z[i])/1000}<br>
<br>
scatterplot3d(k[, 1], k[, 2], cdf, highlight.3d = TRUE, col.axis = 'blue',<br>
mian='Plotting bivariate CDF', pch = 20, ylab = 'values of y',<br>
xlab = 'values of x',<br>
zlab = 'CDF of x+y')*<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://r.789695.n4.nabble.com/Error-incorrect-number-of-dimensions-tp4729807.html" target="_blank" rel="noreferrer">http://r.789695.n4.nabble.com/<wbr>Error-incorrect-number-of-<wbr>dimensions-tp4729807.html</a><br>
Sent from the datatable-help mailing list archive at Nabble.com.<br>
______________________________<wbr>_________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.<wbr>r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank" rel="noreferrer">https://lists.r-forge.r-<wbr>project.org/cgi-bin/mailman/<wbr>listinfo/datatable-help</a><br>
</blockquote></div><br></div>