| compose | R Documentation |
Modify flextable displayed values with eventually mixed content paragraphs.
Function is handling complex formatting as image insertion with
as_image(), superscript with as_sup(), formated
text with as_chunk() and several other chunk functions.
Function mk_par is another name for compose as
there is an unwanted conflict with package 'purrr'.
If you only need to add some content at the end
or the beginning of paragraphs and keep existing
content as it is, functions append_chunks() and
prepend_chunks() should be prefered.
compose(x, i = NULL, j = NULL, value, part = "body", use_dot = FALSE)
mk_par(x, i = NULL, j = NULL, value, part = "body", use_dot = FALSE)
x |
a 'flextable' object, see flextable-package to learn how to create 'flextable' object. |
i |
row selector, see section Row selection with the |
j |
column selector, see section Column selection with the |
value |
a call to function |
part |
part selector, see section Part selection with the |
use_dot |
by default |
fp_text_default(), as_chunk(), as_b(), as_word_field(), labelizor()
Other functions to compose cell content:
append_chunks(),
as_paragraph(),
footnote(),
labelizor(),
prepend_chunks(),
void()
ft_1 <- flextable(head(cars, n = 5), col_keys = c("speed", "dist", "comment"))
ft_1 <- mk_par(
x = ft_1, j = "comment",
i = ~ dist > 9,
value = as_paragraph(
colorize(as_i("speed: "), color = "gray"),
as_sup(sprintf("%.0f", speed))
)
)
ft_1 <- set_table_properties(ft_1, layout = "autofit")
ft_1
# using `use_dot = TRUE` ----
set.seed(8)
dat <- iris[sample.int(n = 150, size = 10), ]
dat <- dat[order(dat$Species), ]
ft_2 <- flextable(dat)
ft_2 <- mk_par(ft_2,
j = ~ . - Species,
value = as_paragraph(
minibar(.,
barcol = "white",
height = .1
)
), use_dot = TRUE
)
ft_2 <- theme_vader(ft_2)
ft_2 <- autofit(ft_2)
ft_2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.