Error with inline code using RMarkdown

I am getting errors in using inline Code in RMarkdown and would like some guidance as to what I am doing wrong

I am on Windows with Default Text Encoding = "UTF-8" under Global Options > Code > Saving

I copied the code from Inline Code and also tried the instructions in 6.4.5 R code in-line in RMarkdown

Base R comes with many functions for generating colors. The code below demonstrates the r colorFunc function.

I get the error code

Error: unexpected symbol in "Base R"

I also tried these

"There are "backtick" r nrow(cars) "backtick" included in this report"

Output: [1] "There are r nrow(cars) included in this report"

'There are r nrow(cars) included in this report'

Output: [1] "There are r nrow(cars) included in this report"

Preview in Viewer shows
"There are r nrow(cars) included in this report"

Thanks in advance,

Hi there,
Welcome to the RStudio Community Forum.
I tried running that Rmarkdown code in both RStudio Cloud and in my own desktop RStudio under Windows 10 (after copy-paste into a new xxx.Rmd file) - it worked fine and produced the coloured volcano map, either by knitting the whole file (to HTML in my case), or by "playing" each chunk of R code. So, not sure what's going wrong.
Those colour palettes are defined in the {grDevices} package. If you run
sessionInfo()
do you see grDevices listed under "attached base packages"?

Do you have a local experienced R user who might look over your shoulder and help?

Thanks DavoWW for responding. No R users at my end

I was doing the wrong thing and running the inline code within the code chunk instead of outside it.

'Total rows are r nrow(cars) ' now previews as ‘Total rows are 50’

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