R Markdown: How do I make text float around figures?

后端 未结 3 2076
刺人心
刺人心 2020-12-16 05:59

I made a flowchart with R which I included in my R Markdown file.

How it looks like right now:

The code:

```{r flowchart-data, echo = FALSE,         


        
3条回答
  •  借酒劲吻你
    2020-12-16 06:03

    As far as I know you can embed HTML code within a markdown document, so if you're knitting to HTML, you can do something like this:

    Wrap the cell with a div tag with the style of alignment you want (no need to align the cell anymore), and as for the caption you can add a transparent box at the bottom with the caption as the text inside

    ```{r flowchart-data, echo = FALSE, message = FALSE, fig.width = 7, fig.height = 6} library(grid) library(Gmisc) grid.newpage() # set some parameters to use repeatedly leftx <- .2 midx <- .5 rightx <- .8 myBoxGrob <- function(text, ...) { boxGrob(label = text, bjust = "top", box_gp = gpar(fill = "lightgrey"), ...) } # create boxes (Pharmazie <- myBoxGrob("Verbrauchsdaten von der\n Spitalpharmazie (Excel-Tabelle)", x=leftx, y=1, width = 0.36)) (Finanzen <- myBoxGrob("Belegzahlen vom Ressort\n Finanzen (Excel-Tabelle)", x=rightx, y=1, width = 0.36)) (A <- myBoxGrob("Import der Daten aus Excel ins\n Microsoft Access (Datenbanksoftware)", x=midx, y=0.83, width = 0.45)) (B <- myBoxGrob("Zusammenführen der Informationen\n und erstellen neuer, berechneter Tabellen", x=midx, y=.66, width = 0.45)) (C <- myBoxGrob("Export der neu erstellten Tabellen\n in Form von Excel-Tabellen", x=midx, y=.49, width = 0.45)) (D <- myBoxGrob("Import der neuen Tabellen in R", x=midx, y=.32, width = 0.45)) (E <- myBoxGrob("Berechnung und grafische Darstellung\n der Grafiken und Tabellen", x=midx, y=.19, width = 0.45)) (caption <- boxGrob(label = 'Ablauf der Datenverarbeitung', x=midx, y=.02, box_gp = gpar(alpha=0))) connectGrob(Pharmazie, A, "L") connectGrob(Finanzen, A, "L") connectGrob(A, B, "N") connectGrob(B, C, "N") connectGrob(C, D, "N") connectGrob(D, E, "N") ```
    And this is the text that would go to the left of the chart.

提交回复
热议问题