Britain's most senior statistician has quit as head of the Office for National Statistics (ONS) in the wake of criticism of potential inaccuracies in some of its economic data.