As a suggestion and answer to previous comment,
A return variable AnDartest is not assigned anywhere so when you trying to assign output of function it fails. So can authors please add correct return statement. e.g.
AnDartest = P; if P-value of the test is required, which I think is the most useful part of the test.