views:

65

answers:

1

I don't think I need to explain exactly what the code does. The point is that while performing the chisq.test outside the loop, I get a result like this (expected):

        Chi-squared test for given probabilities

data:  observed 
X-squared = 185912, df = 5, p-value < 2.2e-16

but when I try to do the test in a loop, the expected result does not appear

total <- dim(crs$dataset_init)[1]
expected.fr <- cl.popul / total

for (i in 1:dim(cl.vs.Onerall)[1] ) {
     if (cl.vs.Onerall[i,1] > 0) {
       observed <- cl.vs.Onerall[i,2:(clust_no + 1)]

       print(rownames(cl.vs.Onerall)[i])
       chisq.test(observed, p=expected.fr)
       print("------------------------------")
    }
}

Any ideas would be greatly appreciated!

A: 

Jonathan Chang you were right. Thank you print print print

gd047