0
votes

I am using RStudio 1.0.136 with R version 3.3.2 When I do File --> New File --> R HTML , it comes up with the template HTML file (with summary(cars) and plot(cars)) But when I click Knit, the resulting HTML file doesn't have either the R code or the output of the code! There are no error or warning messages.

I wondered if I had to manually change at the top to but that doesn't seem to help at all.

What am I missing? Btw, the knitr package version is 1.14

Thanks!

1
I seem to have made some progress by trying a different approach. I installed rmarkdown 1.3 and when I tried it with this: --- title: "Untitled" output: word_document --- {r} summary(cars) {r fig.width=4, fig.height=3} plot(pressure) It generates an HTML file but without any output text or plot! - whirlaway
When the file comes up, there's a Log button at the top. Click that -- do you see any errors in the log? - Jonathan
I didn't see a Log button at the top. But I noticed the console window had a tab named "R Markdown". And its contents seemed to be normal: "C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS rtest.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output rtest.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template .... Output created: rtest.html - whirlaway
Have you tried opening the resulting html file in an external browser like Chrome or Firefox? - Roman Luštrik

1 Answers

0
votes

Solution:

Step 1: Download and Install MiKTeX from http://miktex.org/2.9/setup

Step 2: Run Sys.getenv("PATH") in R studio. This command returns the path where Rstudio is trying to find pdflatex.exe. In windows (64-bit) it should return C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe. If pdflatex.exe is not located in this location Rstudio gives this error code 41.

Step 3: To set this path variable please run Sys.setenv(PATH=paste(Sys.getenv("PATH"),"C:/Program Files/MiKTeX 2.9/miktex/bin/x64/",sep=";"))