Error : unexpected symbol

Entering a command from an R MArkdown file -

{r load-data} data(nycflights)

And this is what I get, why so?-

Error: unexpected symbol in "{r load"

The equivalent in r console would be

data(nycflights)

Rmarkdown is its own language that R console won't interpret. R Markdown has extra syntax with triple backticks and curly braces to label blocks.

If you want this code to run in an R Markdown file (.Rmd) you need:

```{r load-data}
data(nycflights)
```

If you want to run this code in an R Script file (.R) or in the Console, you'd write just:

data(nycflights)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.