1

I was wondering if there might be a way to split Rstudio's Viewer pane (like par(mfrow = 2:1) for the Plot pane) so that I could display 2 flextable objects?

 library('flextable')
 dat1 <- data.frame(Approaches = c("Y", "Y", "N"), Meets = c("N", "Y", "N"), row.names = c("Read", "Math", "Sci."))
 dat2 <- data.frame(Read = "Y", Math = "N")

 flextable(dat1)  # Display this
 flextable(dat2)  # and Display this
r2evans
  • 141,215
  • 6
  • 77
  • 149
rnorouzian
  • 7,397
  • 5
  • 27
  • 72

1 Answers1

2

That's possible with htmltools package:

library(htmltools)
library(flextable)

dat1 <- data.frame(Approaches = c("Y", "Y", "N"), Meets = c("N", "Y", "N"), row.names = c("Read", "Math", "Sci."))
dat2 <- data.frame(Read = "Y", Math = "N")
browsable(tagList(
  htmltools_value(flextable(dat1)),  # Display this
  tags$hr(),
  htmltools_value(flextable(dat2))  # and Display 
))

enter image description here

This is a basic example, you can get much more complex layout with css and htmltools.

David Gohel
  • 9,180
  • 2
  • 16
  • 34
  • right, `row.names` are to be added to the data.frame as a column – David Gohel Dec 20 '19 at 21:29
  • caption is a real caption so you can define its style with css iin R Markdown. caption has been added to let user add captions (mainly used for some features of r markdown and knitr). If your need is to add a siimple formatted title on top/bottom of table, then use `add_header_lines` or `add_footer_lines` and use flextable to control the rendering of the *title* – David Gohel Dec 20 '19 at 21:59