We can try something like
set.seed(1)
observed <- c(2, 1, 4, 2, 2, 2, 1, 1)
prob.exp <- dexp(c(0, 1, 2, 4, 5, 7, 8, 10), rate=0.54) # prob for the exp dist. variable for the values
chisq.test(observed, p=prob.exp, rescale.p = TRUE)
#X-squared = 73.523, df = 7, p-value = 2.86e-13
We can try this also (with theoretical definition):
set.seed(1)
observed <- c(2, 1, 4, 2, 2, 2, 1, 1)
prob.exp <- dexp(c(0, 1, 2, 4, 5, 7, 8, 10), rate=0.54)
prob.exp <- prob.exp / sum(prob.exp) # normalize
expected <- sum(observed)*prob.exp
# expected frequency of the values
chisq.stat <- sum((observed-expected)^2/expected)
# [1] 73.52297
1-pchisq(sum(chisq.stat),df=8-1)
# [1] 2.859935e-13
They exactly give the same result, as expected (null hypothesis for goodness of fit test is rejected, so the data is not from the distribution)