Reputation: 11
B = 10
CC <- numeric(B)
for(j in 1:10)
N = rnorm(1000)
print(ks.test(N,pnorm)$statistic)
CC[j] <- ks.test(N,pnorm)$statistic
print(CC[j])
print(CC)
if you run this in r you will get a matrix with 9 zeros and only the last term is an actually numeric value. Can someone please explain why this is happening and how can i get the numerical values on the other indices.
Upvotes: 1
Views: 387
Reputation: 6567
It could be because of missing {}
. Try this:
B = 10
CC <- numeric(B)
for(j in 1:10) {
N = rnorm(1000)
print(ks.test(N,pnorm)$statistic)
CC[j] <- ks.test(N,pnorm)$statistic
print(CC[j])
}
print(CC)
Upvotes: 2