Unable to knit to HTML

knitr

#1

I'm trying to use the render statement to create an HTML report from an R Markdown file. But following error is encountered:

Error in gregexpr("(?<!(^|\n))`r[ #]([^`]+)\\s*`", "---\ntitle: \"Untitled\"\noutput:\n html_document: default\n \n---\n", : invalid regular expression '(?&lt;!(^| ))r[ #]([^]+)\s*`', reason 'Invalid regexp' Calls: <Anonymous> ... parse_inline -> <Anonymous> -> re_call -> do.call -> gregexpr Execution halted

I am not able to use the 'Knit to HTML' button either - same error. I tried to search the error up online but could not identify anything that point to the cause of the problem. Does anyone know? Really appreciate the help!


#2

Hi,

can you share the rmarkdown you are trying to knit to html ?
Or I least the yaml header where I suspect the error could be from?


#3

Hi cderv,

Thank you for replying. It's a very simple markdown file (name of the file is testHTML.Rmd) with below lines:

---
title: "Untitled"
output:
html_document: default  
---    
## R Markdown
This is a test!

In my main R code, I am calling the render() statement as render('testHTML.Rmd') .

I'm running it on RStudio 1.1.414. The knitr version is 1.19 and rmarkdown version is 1.8


#4

Indentation is important in the yaml header. I don't know if it is a copy paste error but if note, can you try with correct indentation

---
title: "Untitled"
output: html_document
---    
## R Markdown
This is a test!

and if you want to add option

---
title: "Untitled"
output: 
  html_document:
    toc: true
---    
## R Markdown
This is a test!

#5

Hi,

The indentation is messed up in the copy/paste. I did have the right indentation in my program. Here's it and it's not working.


title: "Untitled"
output:
html_document: default


R Markdown

This is a test!

I'm suspecting it's the RStudio setting on our company's server because the same program would run on the other set of server. I'm trying to figure out what needs to be changed.