| align | R Documentation |
Change the text alignment of selected rows and columns of a flextable.
align(
x,
i = NULL,
j = NULL,
align = "left",
part = c("body", "header", "footer", "all")
)
align_text_col(x, align = "left", header = TRUE, footer = TRUE)
align_nottext_col(x, align = "right", header = TRUE, footer = TRUE)
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 |
align |
text alignment - a single character value, or a vector of
character values equal in length to the number of columns selected by If the number of columns is a multiple of the length of the |
part |
part selector, see section Part selection with the |
header |
should the header be aligned with the body |
footer |
should the footer be aligned with the body |
Other formatting shortcuts:
bg(),
bold(),
color(),
empty_blanks(),
font(),
fontsize(),
highlight(),
italic(),
keep_with_next(),
line_spacing(),
padding(),
rotate(),
style(),
tab_settings(),
valign()
# Table of 6 columns
ft_car <- flextable(head(mtcars)[, 2:7])
# All 6 columns right aligned
align(ft_car, align = "right", part = "all")
# Manually specify alignment of each column
align(
ft_car,
align = c("left", "right", "left", "center", "center", "right"),
part = "all"
)
# Center-align column 2 and left-align column 5
align(ft_car, j = c(2, 5), align = c("center", "left"), part = "all")
# Alternate left and center alignment across columns 1-4 for header only
align(ft_car, j = 1:4, align = c("left", "center"), part = "header")
ftab <- flextable(mtcars)
ftab <- align_text_col(ftab, align = "left")
ftab <- align_nottext_col(ftab, align = "right")
ftab
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.