I'm calculating chi-squared goodness of fit test. There are four vegetation types (A–D), each occupies a given % of the total study area, and in each vegetation a total number of specimens was calculated. The question is whether a distribution of a this plant species is proportional to vegetation types areas or not. I ran the test in R and with an online calculator, but the results are very different and only the online calculator returns the correct values (I know the answer).
A <- c(45, 4, 10, 59) #number of specimens in each vegetation, total 118 observations
B <- c(24, 17, 5, 54) #area of each vegetation = % of the total study area
C <- c(28.32, 20.06, 5.9, 63.72) #expected values (area % * 118)
chisq.test(A, C)
The output
Pearson's Chi-squared test
data: A and C
X-squared = 12, df = 9, p-value = 0.2133
Next, I rerun the test with an online calculator (https://www.statology.org/chi-square-goodness-of-fit-test-calculator/) using my observed (A) and expected (C) data and the result is:
X2 Test Statistic: 25.880627
p-value: 0.000010
This is also the correct answer. The question is: what am I doing wrong to have these two tests run so differently?