2

I am fairly new to R markdown (and R itself). I am using RStudio to create an R Markdown file. I would like to create a report that has several different plots across different time windows, each with accompanying text. Something like this:

for (i in seq(0, max)) {
  # generate some text with markdown formatting including the value of i
}

I know that it is possible to embed R values inline in markdown text. Is there also a way to generate markdown text inline within R code?

Aniket Schneider
  • 904
  • 1
  • 8
  • 21
  • `message` prints text at the console without those characters, but are you talking about captions for your figures? There are caption methods that might be more suitable than this approach. – Ben Jul 02 '14 at 19:30
  • Or maybe you want `cat()` rather than `print()`. It's somewhat unclear. – MrFlick Jul 02 '14 at 19:54
  • I have tried to simplify/clarify the question. Did it help? – Aniket Schneider Jul 02 '14 at 19:59
  • It would help more if you included an example of your desired output. – Ben Jul 02 '14 at 22:41

1 Answers1

1

Probably Pander package is what you are looking for. It support markdown renderings for R objects.

Toy example of printing lines of data frame.

d> m <- mtcars[1:4, 1:6]
d> for (i in 1:4)
+     pander(m[i,], style="rmarkdown")



|     &nbsp;      |  mpg  |  cyl  |  disp  |  hp  |  drat  |  wt  |
|:---------------:|:-----:|:-----:|:------:|:----:|:------:|:----:|
|  **Mazda RX4**  |  21   |   6   |  160   | 110  |  3.9   | 2.62 |



|       &nbsp;        |  mpg  |  cyl  |  disp  |  hp  |  drat  |  wt   |
|:-------------------:|:-----:|:-----:|:------:|:----:|:------:|:-----:|
|  **Mazda RX4 Wag**  |  21   |   6   |  160   | 110  |  3.9   | 2.875 |



|      &nbsp;      |  mpg  |  cyl  |  disp  |  hp  |  drat  |  wt  |
|:----------------:|:-----:|:-----:|:------:|:----:|:------:|:----:|
|  **Datsun 710**  | 22.8  |   4   |  108   |  93  |  3.85  | 2.32 |



|        &nbsp;        |  mpg  |  cyl  |  disp  |  hp  |  drat  |  wt   |
|:--------------------:|:-----:|:-----:|:------:|:----:|:------:|:-----:|
|  **Hornet 4 Drive**  | 21.4  |   6   |  258   | 110  |  3.08  | 3.215 |
romants
  • 3,660
  • 1
  • 21
  • 33