R Markdown Notebook Syntax?

Hi Everyone.

I am working on an R Markdown Notebook and it seems like some R script code that I have written is not immediately transferable to an R Markdown Notebook. For example, the following:

image

Why is the text changing color? Is this indicating that there is something wrong? Can I not use this approach? It seems like some aspects are not functioning as I would expect, for example, factor treatment seems incorrect.

This seems to be R code. Right ?

Do you plan to evaluate it ? or is it just for showing purposes ?

You need to put your R code in chunks if you want to evaluate it. Otherwise, any text outside of chunks will be considered as markdown to be rendered.

You get this highlighting because RStudio IDE see that as non-R code because outside of a chunk, and $...$ is a syntax for math expression. Hence what you see.

Hope it helps.

1 Like

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