1

I'm running Rstudio 0.98.490 on Windows 7. Sometimes when I click on "Knit HTML", the output does not include the title section. For example, if the following is my .Rmd,

---
title: "Sample Document"
output: html_document
---

Section 1
--------

blah blah

Then the first thing that shows up in my .html file is "Section 1" instead of "Sample document". This is very bad. How can I ensure that the title shows up?

Additional details: The missing title does not always happen, and I don't know why. Here are several things that I tentatively associate with the missing title:

  • when the title fails to display, a .md file appears in my directory; otherwise it is automatically cleaned up.
  • the title fails to show up every time that a log screen like this shows up during compilation in Rstudio:

enter image description here

What is going on???

zkurtz
  • 3,230
  • 7
  • 28
  • 64
  • The version of pandoc you are using is out of sync with the version of pandoc that comes prebuilt with RStudio. This is why RStudio does it right and your pandoc does it wrong. This stackoverflow link has an answer that shows you how to use the version of pandoc that RStudio uses to convert your Rmd to pdf or html https://stackoverflow.com/questions/11025123/how-to-convert-r-markdown-to-pdf – Eric Leschinski Mar 18 '18 at 23:09

2 Answers2

0

What's happening is that--for some reason--RStudio is not using the new RMarkdown v2 but rather the classic knit-to-HTML feature to render your document.

It's likely that the culprit is an option called rstudio.markdownToHTML (more information about this option is available here: Customizing Markdown Rendering).

If this option is set, then RStudio assumes that you have a custom workflow and doesn't use rmarkdown.

So, three things to try:

  1. Check to see if the option is set immediately after you observe the problem. If it is, you have your culprit. Make sure the option is not set automatically (e.g. you might try searching through your R sources to see if it's getting set in an .Rprofile somewhere)
  2. Make sure you're running the very latest version of RStudio and the rmarkdown package: devtools::install_github("rstudio/rmarkdown"). RStudio won't use the rmarkdown package if it looks out of date.
  3. Finally, if all else fails, you can always render your document manually using rmarkdown: rmarkdown::render("zdlmn.Rmd"). If you have to resort to this, then a post to the RStudio support forums with your sessionInfo() and RStudio/rmarkdown versions would be helpful.
Jonathan
  • 8,497
  • 41
  • 35
  • (1) How can I check if the option is set? (3) This option works only when the ordinary `Knit HTML` button is also working -- see the answer that I've posted. – zkurtz Aug 25 '14 at 12:09
0

There are two ways to open a .Rmd file with Rstudio.

(1) Double-click on the .Rmd file you want to edit, and Rstudio opens with the file loaded in the editor window.

(2) Open Rstudio directly, and then do File -> open ...

On my computer, (2) leads to the good behavior and (1) leads to the bad behavior.

I have no idea why, so I don't consider this to be a "real" answer, but I'm posting this because it's a life-saver for me while I figure out what's really going on.

zkurtz
  • 3,230
  • 7
  • 28
  • 64