Skip to content

gg_chunk in footer/header #589

Answered by davidgohel
okeep asked this question in Q&A
Nov 15, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote
library(flextable)
library(ggplot2)
library(data.table)

temp <- data.table(estimate = rnorm(10))

temp[, `:=`(
  lower.CL = estimate - 1,
  upper.CL = estimate + 1
)]

axis_plot <- ggplot(data = NULL, aes(x = rnorm(1), y = rnorm(1))) +
  geom_point()

temp[, ` ` := list(list(ggplot(data.table(estimate, lower.CL, upper.CL), aes(x = 1, y = estimate, ymin = lower.CL, ymax = upper.CL)) +
                          geom_point() +
                          geom_errorbar())), by = 1:nrow(temp)]

tab <- flextable(temp) |>
  colformat_double(digits = 3) |>
  mk_par(
    j = " ", 
    value = as_paragraph(gg_chunk(value = ., height = 1, width = 2)), use_dot = TRUE) |>
  add_footer( ` ` = "") |> 
  …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@okeep
Comment options

@davidgohel
Comment options

Answer selected by okeep
@okeep
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants