NaN p-value when using R's goodfit on binomial data I am attempting to test the goodness of fit for a vector of count data to a binomial.  To do so I am using the goodfit() function in the vcd package.  When I run the function, however, it returns NaN for the p-value of the Chi-squared test.  In my setup, I have a vector of count data with 75 elements.
> library(vcd)
> counts <- c(32, 35, 44, 35, 41, 33, 42, 49, 36, 41, 42, 45, 38, 43, 36, 
35, 40, 40, 43, 34, 39, 31, 40, 39, 36, 37, 37, 37, 32, 48, 41, 
32, 37, 36, 49, 37, 41, 36, 34, 37, 41, 32, 36, 36, 30, 33, 33, 
42, 39, 36, 36, 29, 31, 41, 36, 39, 40, 37, 39, 39, 31, 39, 37, 
40, 33, 41, 34, 46, 35, 41, 44, 38, 44, 34, 42)
> test.gof <- goodfit(counts, type="binomial", 
+                     par=list(size=length(counts), prob=0.5))

Everything works fine, but when I inspect the goodfit() object I get the following:
> summary(test.gof)

 Goodness-of-fit test for binomial distribution

                      X^2 df  P(> X^2)
Pearson               NaN 75       NaN
Likelihood Ratio 21.48322 19 0.3107244
Warning message:
In summary.goodfit(test.gof) : Chi-squared approximation may be incorrect

I suspected it was a small sample size issue at first, but I also have a data set with 50 observations that does not return NaN for the p-value.  I have also tried to switch the method in goodfit() to ML with similar results.
Why would this function be producing NaN in this case?  Is there an alternative function to calculate GOF on count data?
 A: You have zero frequencies in observed counts. That explains NaNs in your data. If you look at test.gof object, you'll see that:
table(test.gof$observed)

 0  1  2  3  4  5  7  8 10 
56  5  3  2  5  1  1  2  1

you have 56 zeros. Anyway, IMHO this question is for http://stats.stackexchange.com.
A: Would you be happier with a surgically altered goodfit object?
> idx <- which(test.gof$observed != 0)
> idx
 [1] 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 49 50
> test.gof$par$size <- length(  idx-1)
> test.gof$fitted <- test.gof$fitted[idx]
> test.gof$count <- test.gof$count[idx]
> test.gof$observed <- test.gof$observed[idx]
> summary(test.gof)

     Goodness-of-fit test for binomial distribution

                      X^2 df  P(> X^2)
Pearson               Inf 75 0.0000000
Likelihood Ratio 21.48322 19 0.3107244
Warning message:
In summary.goodfit(test.gof) : Chi-squared approximation may be incorrect

A: Try plotting it. You'll get a better idea of what's going on. As mentioned before, you're getting NaN because you're passing 0 frequencies to chisq.test()
test.gof <- goodfit(counts, type="binomial", par=list(size=length(counts), prob=0.5)) 
plot(test.gof)
## doesn't look so good 
test.gof <- goodfit(counts, type="binomial", par=list(size=length(counts))) 
plot(test.gof)
## looks a little more clear

