Search code examples
rrstudioflextableofficer

Splitting Rstudio's Viewer pane: possible?


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

Solution

  • 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.