[Tex/LaTex] pdflatex not found (windows)

markdownpdftexr

I am trying to exporty a pdf file from the R output using R markdown. I donwnloaded the MikTex, but when I tried to run the R markdown, it showed this error message:

pandoc.exe: pdflatex not found. pdflatex is needed for pdf output.

When I typed sessionInfo() in R, I got this:

R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

It seems that R could not find the location of the downloaded latex:

Sys.which("pdflatex")
pdflatex 
  "" 

Not sure if there is something wrong with downloading the MikTex, the location of the downloaded MikTex in my computer is:

"C:\Users\username\Desktop\MiKTeX Download Files"

And I reset the path in R, but still showed the same error:

Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:\\Users\\username\\Desktop\\MikTeX Download Files\\miktex\\bin", sep=.Platform$path.sep))

I know the issue might be related to path setting, but not sure what exactly to do to solve this.
Any ideas?
Thanks!!

Best Answer

I resolved the issue, it turns out that after I complete downloading, I should open the installer again and click on install MikTeX. I thought I just need to use that wizard once. I found a detailed solution here: installation issue