Prometheus
Prometheus

Reputation: 2017

Use variable in Rmarkdown text

I am creating an Rmarkdown document.

My code chunk checks for the number of columns/rows in the dataset and saves the information in a variable.

{r, echo=FALSE, warning=FALSE}
df_dimenzions <- dim(demo)

I want to use the data/information stored in the variable in the rmarkdown text.

For example... outside of the code chunk, to write plain text such as:
The number of columns is {{df_dimensions[1]}} and the number of rows
is {{df_dimension[2]}}

Is something like this possible in rmarkdown? Again, I'm asking for data that is processed within the rmarkdown, not stored outside of the document?

Also, I am aware that I can paste a concatinated string with the code-chunk. That is not what I am trying to achieve.

Upvotes: 13

Views: 16034

Answers (1)

Bing
Bing

Reputation: 1103

Use `r df_dimensions[1]` in the main text.

Upvotes: 20

Related Questions