I_Nz
I_Nz

Reputation: 31

Inline code in r markdown is printed 'as is'

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.

Upvotes: 1

Views: 628

Answers (1)

I_Nz
I_Nz

Reputation: 31

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.

Upvotes: 2

Related Questions