R knit to PDF not working properly with errors

I believe this is a very annoying issue because you may have a space in your Windows username.
There are other issues like that in this community, for example : Failed to run c:/..../pdflatex.exe

There is not a clear fix yet because the source is not well known yet.
You may try to add the directory C:\Users\XXX XXX\AppData\Roaming\TinyTeX\bin\win32 in PATH but I am not sure that will do the trick.