It's probably because \texttt{} looks a lot like a LaTeX command, and when using Rmarkdown with PDF output, your Rmarkdown is actually converted to LaTeX code and executed by pdflatex/tinytex.
So you have two possibilities: you can put that command between backticks ` so that it is interpreted as verbatim, not executed, and formatted as code: \texttt{}
If you don't want it to be formatted as code, you can simply escape the backslash \ with a second one: \\texttt{} and that should be enough to prevent it from being recognized as a LaTeX command.