1

While knitting an R markdown document the inline code is printed 'as is', for example:

- The number of patients in the dataframe is `n_distinct(med1$patients)`.

Is knitted exactly the same:

  • The number of patients in the dataframe is n_distinct(med1$patients).

The code is not evaluated, rather the text is formatted as code. In a previous question someone suggested adding brackets but it doesn't work for me.
Any suggestions will be much appreciated.

OTStats
  • 1,820
  • 1
  • 13
  • 22
I_Nz
  • 31
  • 2
  • Possible duplicate of [R Markdown inline code not executed](https://stackoverflow.com/questions/40519890/r-markdown-inline-code-not-executed) – divibisan Mar 11 '19 at 22:38

1 Answers1

2

I stumbled across the solution. I had to write it this way:

  • The number of patients in the data frame is `r n_distinct(med1$patients)`.

With the extra R in the code made it run as desired.

OTStats
  • 1,820
  • 1
  • 13
  • 22
I_Nz
  • 31
  • 2