0

I have an R Notebook script with the setup chunk defined below. I keep getting this error:

Error in source("~/Documents/testing.Rmd") : 
  ~/Documents/testing.Rmd:11:9: unexpected symbol
10: # Setup  
11: Ensures that

I've read other threads about this error and can't find an error in my syntax for these lines. Any help would be appreciated; the html of the script seems to generate fine, but the error is concerning me.

# Setup  
Ensures that working directory is set for all code chunks and loads packages required for script.

```{r setup}

library(knitr)
library(rmarkdown)
library(stringr)
library(tidyverse)

knitr::opts_knit$set(root.dir = normalizePath("/Users/Documents/"))

```
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Chantal
  • 23
  • 5
  • The error message indicates that the text in question (`# Setup` and `Ensures that …`) is inside a *code chunk* in the document. Take it out of the code chunk and it should work. – Konrad Rudolph Jan 16 '23 at 13:11
  • Thanks for the reply; I can't see how this text is inside a code chunk. The YAML header and first code chunk are closed. I can't see I'm missing any backticks? – Chantal Jan 17 '23 at 10:16
  • Late to the party, but I see the same error message with an old, complex markdown document. It choked on the first line of text, right after the front matter. All chunks were properly closed. However, I have now started to recreate the document chunk by chunk, and the error has disappeared. So for anyone else seeing this -- go and double- or triple-check your code, maybe there's some missing backtick or closing parenthesis. – bovender Jul 26 '23 at 10:12

0 Answers0