correct way to call mathjax in R markdown (output format is html)

Just generate the HTML file and edit it manually by putting

<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_CHTML.js"></script>

at the end of the header.