It may be overkill but you might want to have a look at https://bookdown.org/yihui/rmarkdown-cookbook/.
BTW, Yihui reccomends installing TinyText LaTeX but I prefer to stick with my standard TexLive for Linux.
We probably need some code & sample data to see what those errors are doing.