I'm writing a chi-sq stat test in R and my scalar chisq is being converted to a matrix and I can't figure out why.
The variables used here include
k is a scalar
f is a kxk matrix
n is the number of data points being evaluated
chisq is meant to be a scalar but becomes a matrix each time I run this code.
Any help would be appreciated
for(i in 1:k){
for(j in 1:k){
chisq<-chisq+(f[i,j]-(n/(k^2)))^2
}
}